手动合并老客标签群相关代码

1 parent c66038b5
Showing 18 changed files with 426 additions and 259 deletions
...@@ -83,10 +83,10 @@ ...@@ -83,10 +83,10 @@
<!-- <dependency>--> <dependency>
<!-- <groupId>io.github.leejoker</groupId>--> <groupId>io.github.leejoker</groupId>
<!-- <artifactId>linkwechat-nacos-starter</artifactId>--> <artifactId>linkwechat-nacos-starter</artifactId>
<!-- </dependency>--> </dependency>
......
...@@ -27,16 +27,16 @@ import java.util.List; ...@@ -27,16 +27,16 @@ import java.util.List;
public class WeCommunityH5Controller extends BaseController { public class WeCommunityH5Controller extends BaseController {
@Autowired @Autowired
private IWePresTagGroupTaskService tagGroupTaskService; IWePresTagGroupTaskService tagGroupTaskService;
@Autowired @Autowired
private IWeGroupSopService sopService; IWeGroupSopService sopService;
@Autowired @Autowired
private IWeCommunityKeywordToGroupService keywordToGroupService; IWeCommunityKeywordToGroupService keywordToGroupService;
@Autowired @Autowired
private ISysUserService userService; ISysUserService userService;
/** /**
* 获取任务对应的执行人列表 * 获取任务对应的执行人列表
...@@ -65,8 +65,8 @@ public class WeCommunityH5Controller extends BaseController { ...@@ -65,8 +65,8 @@ public class WeCommunityH5Controller extends BaseController {
AjaxResult res = AjaxResult.success(); AjaxResult res = AjaxResult.success();
if (type.equals(CommunityTaskType.TAG.getType())) { if (type.equals(CommunityTaskType.TAG.getType())) {
// 老客标签建群数据 // 老客标签建群数据
res.put("todo", tagGroupTaskService.getEmplTaskList(emplId, false)); res.put("todo", tagGroupTaskService.getFollowerTaskList(emplId, 0));
res.put("done", tagGroupTaskService.getEmplTaskList(emplId, true)); res.put("done", tagGroupTaskService.getFollowerTaskList(emplId, 1));
} else if (type.equals(CommunityTaskType.SOP.getType())) { } else if (type.equals(CommunityTaskType.SOP.getType())) {
// 群SOP数据 // 群SOP数据
res.put("todo", sopService.getEmplTaskList(emplId, false)); res.put("todo", sopService.getEmplTaskList(emplId, false));
...@@ -75,10 +75,10 @@ public class WeCommunityH5Controller extends BaseController { ...@@ -75,10 +75,10 @@ public class WeCommunityH5Controller extends BaseController {
// 全部数据 // 全部数据
List todoList = new ArrayList(); List todoList = new ArrayList();
List doneList = new ArrayList(); List doneList = new ArrayList();
todoList.addAll(tagGroupTaskService.getEmplTaskList(emplId, false)); todoList.addAll(tagGroupTaskService.getFollowerTaskList(emplId, 0));
todoList.addAll(sopService.getEmplTaskList(emplId, false)); todoList.addAll(sopService.getEmplTaskList(emplId, false));
res.put("todo", todoList); res.put("todo", todoList);
doneList.addAll(tagGroupTaskService.getEmplTaskList(emplId, true)); doneList.addAll(tagGroupTaskService.getFollowerTaskList(emplId, 1));
doneList.addAll(sopService.getEmplTaskList(emplId, true)); doneList.addAll(sopService.getEmplTaskList(emplId, true));
res.put("done", doneList); res.put("done", doneList);
} }
...@@ -99,11 +99,11 @@ public class WeCommunityH5Controller extends BaseController { ...@@ -99,11 +99,11 @@ public class WeCommunityH5Controller extends BaseController {
@GetMapping("/changeStatus") @GetMapping("/changeStatus")
public AjaxResult changeStatus(@RequestParam("taskId") Long taskId, @RequestParam("emplId") String emplId, @RequestParam("type") Integer type) { public AjaxResult changeStatus(@RequestParam("taskId") Long taskId, @RequestParam("emplId") String emplId, @RequestParam("type") Integer type) {
if (type.equals(0)) { if (type.equals(0)) {
return toAjax(tagGroupTaskService.updateEmplTaskStatus(taskId, emplId));
return toAjax(tagGroupTaskService.updateFollowerTaskStatus(taskId, emplId));
} else { } else {
return toAjax(sopService.updateChatSopStatus(taskId, emplId)); return toAjax(sopService.updateChatSopStatus(taskId, emplId));
} }
} }
/** /**
......
...@@ -2,50 +2,49 @@ package com.linkwechat.web.controller.wecom; ...@@ -2,50 +2,49 @@ package com.linkwechat.web.controller.wecom;
import com.linkwechat.common.constant.HttpStatus; import com.linkwechat.common.constant.HttpStatus;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.core.controller.BaseController; import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult; import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.page.TableDataInfo; import com.linkwechat.common.core.page.TableDataInfo;
import com.linkwechat.common.utils.SecurityUtils; import com.linkwechat.common.utils.SecurityUtils;
import com.linkwechat.common.utils.StringUtils; import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.common.utils.bean.BeanUtils;
import com.linkwechat.wecom.domain.WePresTagGroupTask; import com.linkwechat.wecom.domain.WePresTagGroupTask;
import com.linkwechat.wecom.domain.dto.WePresTagGroupTaskDto; import com.linkwechat.wecom.domain.WePresTagGroupTaskStat;
import com.linkwechat.wecom.domain.vo.WePresTagGroupTaskStatVo;
import com.linkwechat.wecom.domain.vo.WePresTagGroupTaskVo; import com.linkwechat.wecom.domain.vo.WePresTagGroupTaskVo;
import com.linkwechat.wecom.domain.vo.WePresTagTaskListVO;
import com.linkwechat.wecom.service.IWePresTagGroupTaskService; import com.linkwechat.wecom.service.IWePresTagGroupTaskService;
import com.linkwechat.wecom.service.IWeGroupCodeService; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List; import java.util.List;
@Api("老客标签建群接口")
@RestController @RestController
@RequestMapping(value = "/wecom/communityPresTagGroup") @RequestMapping(value = "/wecom/communityPresTagGroup")
public class WeCommunityPresTagGroupController extends BaseController { public class WeCommunityPresTagGroupController extends BaseController {
@Autowired @Autowired
private IWePresTagGroupTaskService taskService; IWePresTagGroupTaskService taskService;
@Autowired
private IWeGroupCodeService groupCodeService;
/** /**
* 获取老客标签建群列表数据 * 获取老客标签建群列表数据
*/ */
// @PreAuthorize("@ss.hasPermi('wecom:communitytagGroup:list')") // @PreAuthorize("@ss.hasPermi('wecom:communitytagGroup:list')")
@GetMapping(path = "/list") @GetMapping(path = "/list")
public TableDataInfo<List<WePresTagGroupTaskVo>> getList( @ApiOperation(value = "获取老客标签建群任务分页数据", httpMethod = "GET")
public TableDataInfo<List<WePresTagTaskListVO>> getPage(
@RequestParam(value = "taskName", required = false) String taskName, @RequestParam(value = "taskName", required = false) String taskName,
@RequestParam(value = "sendType", required = false) Integer sendType, @RequestParam(value = "sendType", required = false) Integer sendType,
@RequestParam(value = "createBy", required = false) String createBy, @RequestParam(value = "createBy", required = false) String createBy,
@RequestParam(value = "beginTime", required = false) String beginTime, @RequestParam(value = "beginTime", required = false) String beginTime,
@RequestParam(value = "endTime", required = false) String endTime) { @RequestParam(value = "endTime", required = false) String endTime) {
startPage(); startPage();
List<WePresTagGroupTaskVo> wePresTagGroupTaskVoList = taskService.selectTaskList(taskName, sendType, createBy, beginTime, endTime); List<WePresTagTaskListVO> result = taskService.selectTaskList(taskName, sendType, createBy, beginTime, endTime);
return getDataTable(wePresTagGroupTaskVoList); return getDataTable(result);
} }
/** /**
...@@ -53,28 +52,16 @@ public class WeCommunityPresTagGroupController extends BaseController { ...@@ -53,28 +52,16 @@ public class WeCommunityPresTagGroupController extends BaseController {
*/ */
// @PreAuthorize("@ss.hasPermi('wecom:communitytagGroup:add')") // @PreAuthorize("@ss.hasPermi('wecom:communitytagGroup:add')")
@PostMapping @PostMapping
public AjaxResult addTask(@RequestBody @Validated WePresTagGroupTaskDto wePresTagGroupTaskDto) { @ApiOperation(value = "新建老客标签建群任务", httpMethod = "POST")
if (null == groupCodeService.getById(wePresTagGroupTaskDto.getGroupCodeId())) { public AjaxResult add(@RequestBody @Validated WePresTagGroupTask task) {
return AjaxResult.error(HttpStatus.NOT_FOUND, "群活码不存在");
}
WePresTagGroupTask task = new WePresTagGroupTask();
BeanUtils.copyProperties(wePresTagGroupTaskDto, task);
// 检测任务名是否可用 // 检测任务名是否可用
if (taskService.isNameOccupied(task)) { if (taskService.isNameOccupied(task)) {
return AjaxResult.error("任务名已存在"); return AjaxResult.error("任务名已存在");
} }
task.setCreateBy(SecurityUtils.getUsername()); task.setCreateBy(SecurityUtils.getUsername());
List<String> tagList = wePresTagGroupTaskDto.getTagList(); int affectedRows = taskService.add(task);
List<String> scopeList = wePresTagGroupTaskDto.getScopeList(); // 再发送消息
int affectedRows = taskService.add(task, tagList, scopeList); if (affectedRows > 0) taskService.sendMessage(task);
if (affectedRows > 0) {
boolean hasScope = StringUtils.isNotEmpty(wePresTagGroupTaskDto.getScopeList());
boolean hasTag = StringUtils.isNotEmpty(wePresTagGroupTaskDto.getTagList());
List<String> externalIds = taskService
.selectExternalUserIds(task.getTaskId(), hasScope, hasTag, wePresTagGroupTaskDto.getSendScope(),
wePresTagGroupTaskDto.getCusBeginTime(), wePresTagGroupTaskDto.getCusEndTime());
taskService.sendMessage(task, externalIds);
}
return toAjax(affectedRows); return toAjax(affectedRows);
} }
...@@ -83,7 +70,8 @@ public class WeCommunityPresTagGroupController extends BaseController { ...@@ -83,7 +70,8 @@ public class WeCommunityPresTagGroupController extends BaseController {
*/ */
// @PreAuthorize("@ss.hasPermi('wecom:communitytagGroup:query')") // @PreAuthorize("@ss.hasPermi('wecom:communitytagGroup:query')")
@GetMapping(path = "/{id}") @GetMapping(path = "/{id}")
public AjaxResult getTask(@PathVariable("id") Long id) { @ApiOperation(value = "根据获取任务详细信息", httpMethod = "GET")
public AjaxResult getInfo(@PathVariable("id") Long id) {
WePresTagGroupTaskVo taskVo = taskService.getTaskById(id); WePresTagGroupTaskVo taskVo = taskService.getTaskById(id);
if (StringUtils.isNull(taskVo)) { if (StringUtils.isNull(taskVo)) {
return AjaxResult.error(HttpStatus.NOT_FOUND, "群活码不存在"); return AjaxResult.error(HttpStatus.NOT_FOUND, "群活码不存在");
...@@ -96,11 +84,15 @@ public class WeCommunityPresTagGroupController extends BaseController { ...@@ -96,11 +84,15 @@ public class WeCommunityPresTagGroupController extends BaseController {
*/ */
// @PreAuthorize("@ss.hasPermi('wecom:communitytagGroup:edit')") // @PreAuthorize("@ss.hasPermi('wecom:communitytagGroup:edit')")
@PutMapping(path = "/{id}") @PutMapping(path = "/{id}")
public AjaxResult updateTask(@PathVariable("id") Long id, @RequestBody @Validated WePresTagGroupTaskDto wePresTagGroupTaskDto) { @ApiOperation(value = "更新任务信息", httpMethod = "PUT")
if (null == groupCodeService.getById(wePresTagGroupTaskDto.getGroupCodeId())) { public AjaxResult update(@PathVariable("id") Long id, @RequestBody @Validated WePresTagGroupTask task) {
return AjaxResult.error(HttpStatus.NOT_FOUND, "群活码不存在"); // 保存新任务
} task.setTaskId(id);
return toAjax(taskService.updateTask(id, wePresTagGroupTaskDto)); task.setUpdateBy(SecurityUtils.getUsername());
task.setUpdateTime(new Date());
int rows = taskService.updateTask(task);
if (rows > 0) taskService.sendMessage(task);
return toAjax(rows);
} }
/** /**
...@@ -108,7 +100,8 @@ public class WeCommunityPresTagGroupController extends BaseController { ...@@ -108,7 +100,8 @@ public class WeCommunityPresTagGroupController extends BaseController {
*/ */
// @PreAuthorize("@ss.hasPermi('wecom:communitytagGroup:remove')") // @PreAuthorize("@ss.hasPermi('wecom:communitytagGroup:remove')")
@DeleteMapping(path = "/{ids}") @DeleteMapping(path = "/{ids}")
public AjaxResult batchRemoveTask(@PathVariable("ids") Long[] ids) { @ApiOperation(value = "批量删除老客标签建群任务", httpMethod = "DELETE")
public AjaxResult batchRemove(@PathVariable("ids") Long[] ids) {
return toAjax(taskService.batchRemoveTaskByIds(ids)); return toAjax(taskService.batchRemoveTaskByIds(ids));
} }
...@@ -117,16 +110,17 @@ public class WeCommunityPresTagGroupController extends BaseController { ...@@ -117,16 +110,17 @@ public class WeCommunityPresTagGroupController extends BaseController {
*/ */
// @PreAuthorize("@ss.hasPermi('wecom:communitytagGroup:query')") // @PreAuthorize("@ss.hasPermi('wecom:communitytagGroup:query')")
@GetMapping(path = "/stat/{id}") @GetMapping(path = "/stat/{id}")
public TableDataInfo<List<WePresTagGroupTaskStatVo>> getStatInfo( public TableDataInfo<List<WePresTagGroupTaskStat>> getStatInfo(
@PathVariable("id") Long id, @PathVariable("id") Long id,
@RequestParam(value = "customerName", required = false) String customerName, @RequestParam(value = "customerName", required = false) String customerName,
@RequestParam(value = "isInGroup", required = false) Integer isInGroup, @RequestParam(value = "isInGroup", required = false) Integer isInGroup,
@RequestParam(value = "isSent", required = false) Integer isSent @RequestParam(value = "isSent", required = false) Integer isSent
) { ) {
WePresTagGroupTask task = taskService.getById(id);
startPage(); startPage();
List<WePresTagGroupTaskStatVo> statVoList = taskService.getStatByTaskId(id); List<WePresTagGroupTaskStat> stats = taskService.getTaskStat(id, customerName, isInGroup, isSent, task.getSendType());
return getDataTable(statVoList); return getDataTable(stats);
} }
......
...@@ -411,4 +411,10 @@ public class WeConstans { ...@@ -411,4 +411,10 @@ public class WeConstans {
* 群发消息任务开关 * 群发消息任务开关
*/ */
public static Boolean WEGROUPMSGTIMEDTASK_SWITCH = true; public static Boolean WEGROUPMSGTIMEDTASK_SWITCH = true;
/**
* 老客标签建群企业群发消息模板
*/
public static final String MSG_TEMPLATE = "你有一个新社群运营任务,<a href='%s?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect'>请点击此链接查看详情</a>";
} }
package com.linkwechat.wecom.client;
import com.dtflys.forest.annotation.*;
import com.linkwechat.wecom.domain.dto.msgaudit.WeMsgAuditDto;
import com.linkwechat.wecom.domain.vo.WeMsgAuditVo;
import com.linkwechat.wecom.interceptor.WeAccessTokenInterceptor;
import com.linkwechat.wecom.interceptor.WeChatAccessTokenInterceptor;
import com.linkwechat.wecom.retry.WeCommonRetryWhen;
/**
* @author danmo
* @description 会话存档接口
* @date 2020/12/2 16:45
**/
@BaseRequest(baseURL = "${weComServerUrl}${weComePrefix}", interceptor = WeChatAccessTokenInterceptor.class)
@Retry(maxRetryCount = "3", maxRetryInterval = "1000", condition = WeCommonRetryWhen.class)
public interface WeMsgAuditClient {
/**
* 获取会话内容存档开启成员列表
*/
@Request(url = "/msgaudit/get_permit_user_list",
type = "POST"
)
WeMsgAuditDto getPermitUserList(@JSONBody WeMsgAuditDto msgAuditDto);
/**
* 单聊 获取会话中外部成员的同意情况
* @param msgAuditDto
* @return
*/
@Request(url = "/msgaudit/check_single_agree",
type = "POST"
)
WeMsgAuditDto checkSingleAgree(@JSONBody WeMsgAuditDto msgAuditDto);
/**
* 群聊 获取群会话中外部成员的同意情况
* @param weMsgAuditVo
* @return
*/
@Request(url = "/msgaudit/check_room_agree",
type = "POST"
)
WeMsgAuditDto checkRoomAgree(@JSONBody WeMsgAuditVo weMsgAuditVo);
/**
* 获取会话内容存档内部群信息
* @param weMsgAuditVo
* @return
*/
@Request(url = "/msgaudit/groupchat/get",
type = "POST"
)
WeMsgAuditDto getGroupChat(@JSONBody WeMsgAuditVo weMsgAuditVo);
}
package com.linkwechat.wecom.domain; package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.annotation.TableLogic; import com.fasterxml.jackson.annotation.JsonFormat;
import com.baomidou.mybatisplus.annotation.TableName;
import com.linkwechat.common.core.domain.BaseEntity; import com.linkwechat.common.core.domain.BaseEntity;
import com.linkwechat.common.utils.SnowFlakeUtil; import com.linkwechat.common.utils.SnowFlakeUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.Date;
import java.util.List;
@ApiModel
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@TableName("we_pres_tag_group") @TableName("we_pres_tag_group")
...@@ -19,57 +27,104 @@ public class WePresTagGroupTask extends BaseEntity { ...@@ -19,57 +27,104 @@ public class WePresTagGroupTask extends BaseEntity {
/** /**
*主键ID *主键ID
*/ */
@ApiModelProperty("id")
@TableId @TableId
private Long taskId = SnowFlakeUtil.nextId(); private Long taskId = SnowFlakeUtil.nextId();
/** /**
* 任务名称 * 任务名称
*/ */
@ApiModelProperty("任务名")
@NotNull(message = "任务名称不能为空")
private String taskName; private String taskName;
/** /**
* 加群引导语 * 加群引导语
*/ */
@ApiModelProperty("加群引导语")
@Size(max = 64, message = "引导与不能超过64字符")
@NotBlank(message = "引导语不能为空")
private String welcomeMsg; private String welcomeMsg;
/** /**
* 发送方式 0: 企业群发 1:个人群发 * 发送方式 0: 企业群发 1:个人群发
*/ */
@ApiModelProperty("加群引导语")
@NotNull(message = "发送方式不能为空")
private Integer sendType; private Integer sendType;
/** /**
* 群活码id * 群活码id
*/ */
@ApiModelProperty("群活码id")
@NotNull(message = "活码不能为空")
private Long groupCodeId; private Long groupCodeId;
/** /**
* 发送范围 0: 全部客户 1:部分客户 * 发送范围 0: 全部客户 1:部分客户
*/ */
@ApiModelProperty("发送范围 0: 全部客户 1:部分客户")
private Integer sendScope; private Integer sendScope;
/** /**
* 发送性别 0: 全部 1: 男 2: 女 3:未知 * 发送性别 0: 全部 1: 男 2: 女 3:未知
*/ */
@ApiModelProperty("发送性别 0: 全部 1: 男 2: 女 3:未知")
private Integer sendGender; private Integer sendGender;
/** /**
* 目标客户被添加起始时间 * 目标客户被添加起始时间
*/ */
private String cusBeginTime; @ApiModelProperty("目标客户被添加起始时间")
@JsonFormat(pattern = "yyyy-MM-dd")
@TableField(updateStrategy = FieldStrategy.IGNORED)
private Date cusBeginTime;
/** /**
* 目标客户被添加结束时间 * 目标客户被添加结束时间
*/ */
private String cusEndTime; @ApiModelProperty("目标客户被添加结束时间")
@JsonFormat(pattern = "yyyy-MM-dd")
@TableField(updateStrategy = FieldStrategy.IGNORED)
private Date cusEndTime;
/** /**
* 企业群发消息的id * 群发消息id
*/ */
private String msgid; @ApiModelProperty(value = "目标客户被添加结束时间", hidden = true)
private Long messageTemplateId;
/** /**
* 逻辑删除字段 * 逻辑删除字段
*/ */
@TableLogic(value = "0", delval = "1") @ApiModelProperty(value = "逻辑删除字段", hidden = true)
private Integer delFlag; private Integer delFlag = 0;
/**
* 客户标签
*/
@ApiModelProperty("客户标签id列表")
@TableField(exist = false)
private List<String> tagList;
/**
* 选择员工
*/
@ApiModelProperty("员工id列表")
@TableField(exist = false)
private List<String> scopeList;
/**
* 群活码链接
*/
@ApiModelProperty("群活码链接")
@TableField(exist = false)
private String codeUrl;
/**
* 当前群总人数
*/
@ApiModelProperty("当前群总人数")
@TableField(exist = false)
private Integer totalNumber;
} }
package com.linkwechat.wecom.domain; package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.linkwechat.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
/** /**
* 老客户标签建群任务使用人对象 * 老客户标签建群任务使用人对象
*/ */
@ApiModel("老客户标签建群跟进者")
@EqualsAndHashCode(callSuper = true)
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@TableName("we_pres_tag_group_scope") @TableName("we_pres_tag_group_scope")
public class WePresTagGroupTaskScope { public class WePresTagGroupTaskScope extends BaseEntity {
private static final long serialVersionUID = 86648978618184060L;
/** /**
* 老客户标签建群任务id * 老客户标签建群任务id
*/ */
@ApiModelProperty("老客户标签建群任务id")
private Long taskId; private Long taskId;
/** /**
* 任务目标员工id * 任务目标员工id
*/ */
@ApiModelProperty("任务目标员工id")
private String weUserId; private String weUserId;
/**
* 是否已处理
*/
private boolean isDone;
@ApiModelProperty(value = "有效标识", hidden = true)
@JsonIgnore
private Integer delFlag = 0;
} }
package com.linkwechat.wecom.domain; package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import com.linkwechat.common.core.domain.BaseEntity; import com.linkwechat.common.core.domain.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import lombok.NoArgsConstructor;
/** /**
* 老客户标签建群客户统计 * 老客户标签建群客户统计(用于个人群发类型的统计)
*/ */
@ApiModel("老客标签建群发送统计对象")
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@TableName("we_pres_tag_group_stat") @TableName("we_pres_tag_group_stat")
public class WePresTagGroupTaskStat extends BaseEntity { public class WePresTagGroupTaskStat extends BaseEntity {
private static final long serialVersionUID = 504772877084507165L;
/** /**
* 老客户标签建群任务id * 老客户标签建群任务id
*/ */
@ApiModelProperty("老客户标签建群任务id")
private Long taskId; private Long taskId;
/** /**
* 客户id * 客户名称
*/ */
@ApiModelProperty("客户名称")
@TableField(exist = false)
private String customerName; private String customerName;
/** /**
* 跟进者id
*/
@ApiModelProperty("跟进者")
private String userId;
/**
* 客户external_id
*/
@ApiModelProperty("老客户标签建群任务id")
@TableField(value = "external_userid")
private String externalUserId;
/**
* 是否已送达 * 是否已送达
*/ */
private boolean isSent; @ApiModelProperty("老客户标签建群任务id")
private Integer sent = 0;
/** /**
* 是否已经在群 * 是否已经在群
*/ */
private boolean isInGroup; @ApiModelProperty("老客户标签建群任务id")
@TableField(exist = false)
private Integer inGroup = 0;
@ApiModelProperty(value = "有效标识", hidden = true)
@JsonIgnore
private Integer delFlag = 0;
} }
package com.linkwechat.wecom.domain; package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.linkwechat.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
/** /**
* 老客标签建群任务标签关联对象 * 老客标签建群任务标签关联对象
*/ */
@ApiModel("老客标签建群标签")
@EqualsAndHashCode(callSuper = true)
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@TableName("we_pres_tag_group_tag") @TableName("we_pres_tag_group_tag")
public class WePresTagGroupTaskTag { public class WePresTagGroupTaskTag extends BaseEntity {
private static final long serialVersionUID = 4859443233276436220L;
/** /**
* 老客建群任务id * 老客建群任务id
*/ */
@ApiModelProperty("老客建群任务id")
private Long taskId; private Long taskId;
/** /**
* 标签id * 标签id
*/ */
@ApiModelProperty("标签id")
private String tagId; private String tagId;
/**
* 有效标识
*/
@ApiModelProperty("有效标识")
@JsonIgnore
private Integer delFlag = 0;
} }
package com.linkwechat.wecom.domain.vo;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class SenderInfo implements Serializable {
private static final long serialVersionUID = 3912731370147355807L;
/**
* 跟进员工user_id
*/
private String userId;
/**
* 客户external_userid
*/
private String customerList;
}
package com.linkwechat.wecom.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
@ApiModel("老客标签建群列表接口简略信息")
@Data
public class WePresTagTaskListVO implements Serializable {
private static final long serialVersionUID = -2266869943970611146L;
@ApiModelProperty("任务id")
private Long taskId;
@ApiModelProperty("任务名")
private String taskName;
@ApiModelProperty("标签名列表")
private List<String> tagList;
@ApiModelProperty("发送类型 0: 企业群发 1: 个人群发")
private Integer sendType;
// @ApiModelProperty("群活码id")
// private String codeId;
//
// @ApiModelProperty("群活码URL")
// private String codeUrl;
@ApiModelProperty("当前群人数")
private Integer totalMember;
@ApiModelProperty("创建时间")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date createTime;
@ApiModelProperty("创建者")
@JsonFormat(pattern = "yyyy-MM-dd")
private String createBy;
@JsonIgnore
private String tagListStr;
}
package com.linkwechat.wecom.mapper; package com.linkwechat.wecom.mapper;
import com.linkwechat.wecom.domain.WeCustomer;
import com.linkwechat.wecom.domain.vo.SenderInfo;
import com.linkwechat.wecom.domain.vo.WePresTagGroupTaskVo; import com.linkwechat.wecom.domain.vo.WePresTagGroupTaskVo;
import com.linkwechat.wecom.domain.vo.WePresTagTaskListVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WePresTagGroupTask; import com.linkwechat.wecom.domain.WePresTagGroupTask;
import org.springframework.security.core.parameters.P;
import java.util.List; import java.util.List;
...@@ -16,27 +18,6 @@ import java.util.List; ...@@ -16,27 +18,6 @@ import java.util.List;
public interface WePresTagGroupTaskMapper extends BaseMapper<WePresTagGroupTask> { public interface WePresTagGroupTaskMapper extends BaseMapper<WePresTagGroupTask> {
/** /**
* 添加新任务
* @param task 老客标签建群任务
* @return 结果
*/
int insertTask(WePresTagGroupTask task);
/**
* 更新任务
* @param task 建群任务信息
* @return 结果
*/
int updateTask(WePresTagGroupTask task);
/**
* 获取老客户标签建群任务
*
* @param taskId 任务id
* @return 结果
*/
WePresTagGroupTaskVo selectTaskById(Long taskId);
/**
* 根据条件查询老客标签建群任务 * 根据条件查询老客标签建群任务
* *
* @param taskName 任务名称 * @param taskName 任务名称
...@@ -46,36 +27,68 @@ public interface WePresTagGroupTaskMapper extends BaseMapper<WePresTagGroupTask> ...@@ -46,36 +27,68 @@ public interface WePresTagGroupTaskMapper extends BaseMapper<WePresTagGroupTask>
* @param sendType 发送方式 * @param sendType 发送方式
* @return 结果 * @return 结果
*/ */
List<WePresTagGroupTaskVo> selectTaskList( List<WePresTagTaskListVO> selectListVO(@Param("taskName") String taskName,
@Param("taskName") String taskName,
@Param("sendType") Integer sendType, @Param("sendType") Integer sendType,
@Param("createBy") String createBy, @Param("createBy") String createBy,
@Param("beginTime") String beginTime, @Param("beginTime") String beginTime,
@Param("endTime") String endTime @Param("endTime") String endTime);
);
/**
* 获取老客户标签建群任务
*
* @param taskId 任务id
* @return 结果
*/
WePresTagGroupTaskVo selectTaskById(Long taskId);
/** /**
* 获取某员工的任务 * 获取某员工的任务
* *
* @param emplId 员工id * @param followerId 员工id
* @param isDone 已完成的还是待处理 * @param isDone 已完成的还是待处理
* @return 结果 * @return 结果
*/ */
List<WePresTagGroupTaskVo> getTaskListByEmplId(@Param("emplId") String emplId, @Param("isDone") boolean isDone); List<WePresTagGroupTaskVo> getTaskListByFollowerId(@Param("followerId") String followerId, @Param("isDone") Integer isDone);
/** /**
* 根据task获取员工信息 * 获取指定条件的外部联系人id,且需要排除已经在群的客户
* @param task *
* @return * @param taskId 标签建群任务id
* @return 客户的external_userids字段值数组
*/ */
List<String> selectStaffList(WePresTagGroupTask task); List<WeCustomer> selectTaskExternalIds(@Param("taskId") Long taskId);
List<String> selectExternalUserIds( /**
@Param("taskId") Long taskId, * 获取指定条件的外部联系人id,且需要排除已经在群的客户
@Param("hasScope") boolean hasScope, *
@Param("hasTag") boolean hasTag, * @param taskId 标签建群任务id
@Param("gender") Integer gender, * @return 客户的external_userids字段值数组
@Param("beginTime") String beginTime, */
@Param("endTime") String endTime List<SenderInfo> selectSenderInfo(@Param("taskId") Long taskId);
);
/**
* 获取指定条件的员工id
*
* @param taskId 标签建群任务id
* @return 获取目标客户对应员工的id数组
*/
List<String> selectTaskFollowerIds(@Param("taskId") Long taskId);
/**
* 根据任务id和员工id获取客户的external_id
*
* @param taskId 任务id
* @param followerId 跟进者user_id字段
* @return 客户external_id列表
*/
List<String> selectTaskExternalByFollowerId(@Param("taskId") Long taskId, @Param("followerId") String followerId);
/**
* 通过taskId获取所有对应群聊的客户的external_id, 用于个人群发的统计
*
* @param taskId 老客标签建群任务id
* @return 结果
*/
List<String> getGroupMemberExternalIdsByTaskId(Long taskId);
} }
...@@ -11,22 +11,21 @@ import org.springframework.stereotype.Repository; ...@@ -11,22 +11,21 @@ import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
@Mapper @Mapper
@Repository
public interface WePresTagGroupTaskStatMapper extends BaseMapper<WePresTagGroupTaskStat> { public interface WePresTagGroupTaskStatMapper extends BaseMapper<WePresTagGroupTaskStat> {
int batchSave(List<WePresTagGroupTaskStat> stats);
/** /**
* 根据 老客标签建群任务id及附属相关属性条件获取任务对应的客户统计 * 获取老客标签建群任务的消息发送结果
* * @param stat 过滤条件
* @param taskId 任务id * @return 发送结果列表
* @return 客户统计列表
*/ */
List<WePresTagGroupTaskStatVo> selectStatInfoByTaskId(@Param("taskId") Long taskId); List<WePresTagGroupTaskStat> cropSendResultList(WePresTagGroupTaskStat stat);
/** /**
* 通过taskId获取所有外部联系人id * 获取老客标签建群任务的消息发送结果
* * @param stat 过滤条件
* @param taskId 老客标签建群任务id * @return 发送结果列表
* @return 结果
*/ */
List<String> getAllExternalIdByTaskId(Long taskId); List<WePresTagGroupTaskStat> singleSendResultList(WePresTagGroupTaskStat stat);
} }
package com.linkwechat.wecom.service; package com.linkwechat.wecom.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WePresTagGroupTask; import com.linkwechat.wecom.domain.WePresTagGroupTask;
import com.linkwechat.wecom.domain.WeTag; import com.linkwechat.wecom.domain.WePresTagGroupTaskStat;
import com.linkwechat.wecom.domain.dto.WePresTagGroupTaskDto;
import com.linkwechat.wecom.domain.vo.WeCommunityTaskEmplVo; import com.linkwechat.wecom.domain.vo.WeCommunityTaskEmplVo;
import com.linkwechat.wecom.domain.vo.WePresTagGroupTaskVo; import com.linkwechat.wecom.domain.vo.WePresTagGroupTaskVo;
import com.linkwechat.wecom.domain.vo.WePresTagGroupTaskStatVo; import com.linkwechat.wecom.domain.vo.WePresTagTaskListVO;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
/** /**
* 社区运营 老客户标签建群 相关逻辑 * 社区运营 老客户标签建群 相关逻辑
*/ */
public interface IWePresTagGroupTaskService { public interface IWePresTagGroupTaskService extends IService<WePresTagGroupTask> {
/** /**
* 添加新标签建群任务 * 添加新标签建群任务
* *
* @param task 建群任务本体信息 * @param task 建群任务本体信息
* @param tagIdList 标签列表
* @param emplIdList 员工列表
* @return 结果 * @return 结果
*/ */
int add(WePresTagGroupTask task, List<String> tagIdList, List<String> emplIdList); int add(WePresTagGroupTask task);
/** /**
* 根据条件查询任务列表 * 根据条件查询任务列表
...@@ -35,7 +32,7 @@ public interface IWePresTagGroupTaskService { ...@@ -35,7 +32,7 @@ public interface IWePresTagGroupTaskService {
* @param endTime 结束时间 * @param endTime 结束时间
* @return 结果 * @return 结果
*/ */
List<WePresTagGroupTaskVo> selectTaskList(String taskName, Integer sendType, String createBy, String beginTime, String endTime); List<WePresTagTaskListVO> selectTaskList(String taskName, Integer sendType, String createBy, String beginTime, String endTime);
/** /**
* 通过id获取老客标签建群任务 * 通过id获取老客标签建群任务
...@@ -56,20 +53,22 @@ public interface IWePresTagGroupTaskService { ...@@ -56,20 +53,22 @@ public interface IWePresTagGroupTaskService {
/** /**
* 更新老客户标签建群任务 * 更新老客户标签建群任务
* *
* @param taskId 待更新任务id * @param task 待更新任务
* @param wePresTagGroupTaskDto 更新数据
* @return 更新条数 * @return 更新条数
*/ */
int updateTask(Long taskId, WePresTagGroupTaskDto wePresTagGroupTaskDto); int updateTask(WePresTagGroupTask task);
/** /**
* 通过老客标签建群id获取其统计信息 * 根据查询条件获取任务的统计结果
* *
* @param taskId 任务id * @param id 任务id
* @return 统计信息 * @param customerName 客户名
* @param isInGroup 是否在群
* @param isSent 是否送达
* @param sendType 发送类型 0 企业群发 1 个人群发
* @return 统计结果
*/ */
List<WePresTagGroupTaskStatVo> getStatByTaskId(Long taskId); List<WePresTagGroupTaskStat> getTaskStat(Long id, String customerName, Integer isInGroup, Integer isSent, Integer sendType);
/** /**
* 根据任务id获取对应员工信息列表 * 根据任务id获取对应员工信息列表
...@@ -80,37 +79,29 @@ public interface IWePresTagGroupTaskService { ...@@ -80,37 +79,29 @@ public interface IWePresTagGroupTaskService {
List<WeCommunityTaskEmplVo> getScopeListByTaskId(Long taskId); List<WeCommunityTaskEmplVo> getScopeListByTaskId(Long taskId);
/** /**
* 根据任务id获取对应标签信息列表
*
* @param taskId 任务id
* @return 结果
*/
List<WeTag> getTagListByTaskId(Long taskId);
/**
* 获取员工建群任务信息 * 获取员工建群任务信息
* *
* @param emplId 员工id * @param emplId 员工id
* @param isDone 是否已处理 * @param isDone 是否已处理
* @return 结果 * @return 结果
*/ */
List<WePresTagGroupTaskVo> getEmplTaskList(String emplId, boolean isDone); List<WePresTagGroupTaskVo> getFollowerTaskList(String emplId, Integer isDone);
/** /**
* 员工发送信息后,变更其任务状态为 "完成" * 员工在H5任务页面发送信息后,变更其任务状态为 "完成"
* *
* @param taskId 任务id * @param taskId 任务id
* @param emplId 员工id * @param followerId 跟进者id
* @return 结果 * @return 结果
*/ */
int updateEmplTaskStatus(Long taskId, String emplId); int updateFollowerTaskStatus(Long taskId, String followerId);
/** /**
* 根据标签建群任务信息发送消息 * 根据标签建群任务信息发送消息
* *
* @param task 标签建群任务 * @param task 标签建群任务id
*/ */
void sendMessage(WePresTagGroupTask task, List<String> externalIds); void sendMessage(WePresTagGroupTask task);
/** /**
* 任务名是否已占用 * 任务名是否已占用
...@@ -120,12 +111,19 @@ public interface IWePresTagGroupTaskService { ...@@ -120,12 +111,19 @@ public interface IWePresTagGroupTaskService {
*/ */
boolean isNameOccupied(WePresTagGroupTask task); boolean isNameOccupied(WePresTagGroupTask task);
List<String> selectExternalUserIds( /**
Long taskId, * 获取外部联系人id, 用于企业群发的 external_userid参数
boolean hasScope, *
boolean hasTag, * @param taskId 任务id
Integer gender, * @return 外部联系人id
String beginTime, */
String endTime List<String> selectExternalIds(Long taskId);
);
/**
* 获取某个任务选择范围内客户对应的员工id, 用于个人群发的touser参数
*
* @param taskId 任务id
* @return 员工id列表
*/
List<String> selectFollowerIdByTaskId(Long taskId);
} }
...@@ -18,7 +18,6 @@ import com.linkwechat.common.utils.Threads; ...@@ -18,7 +18,6 @@ import com.linkwechat.common.utils.Threads;
import com.linkwechat.common.utils.spring.SpringUtils; import com.linkwechat.common.utils.spring.SpringUtils;
import com.linkwechat.wecom.annotation.SynchRecord; import com.linkwechat.wecom.annotation.SynchRecord;
import com.linkwechat.wecom.client.WeCustomerClient; import com.linkwechat.wecom.client.WeCustomerClient;
import com.linkwechat.wecom.client.WeMsgAuditClient;
import com.linkwechat.wecom.client.WeUserClient; import com.linkwechat.wecom.client.WeUserClient;
import com.linkwechat.wecom.constants.SynchRecordConstants; import com.linkwechat.wecom.constants.SynchRecordConstants;
import com.linkwechat.wecom.domain.WeCustomerAddUser; import com.linkwechat.wecom.domain.WeCustomerAddUser;
......
...@@ -4,52 +4,81 @@ ...@@ -4,52 +4,81 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.linkwechat.wecom.mapper.WePresTagGroupTaskStatMapper"> <mapper namespace="com.linkwechat.wecom.mapper.WePresTagGroupTaskStatMapper">
<resultMap type="WePresTagGroupTaskStatVo" id="WePresTagGroupTaskStatResult">
<result property="customerName" column="customer_name" />
<result property="isSent" column="is_sent" />
<result property="isInGroup" column="is_in_group" />
</resultMap>
<delete id="removeStatByTaskId" parameterType="Long"> <insert id="batchSave">
delete from we_pres_tag_group_stat where task_id = #{taskId} insert into we_pres_tag_group_stat (task_id, user_id, external_userid, sent, create_by, create_time) values
</delete> <foreach item="item" index="index" collection="list" separator=",">
(#{item.taskId}, #{item.userId}, #{item.externalUserId}, #{item.sent}, #{item.createBy}, #{item.createTime})
</foreach>
</insert>
<select id="cropSendResultList" parameterType="com.linkwechat.wecom.domain.WePresTagGroupTaskStat" resultType="com.linkwechat.wecom.domain.WePresTagGroupTaskStat">
select distinct
wc.name as customerName,
(case wgmsr.`status` when 0 then 0 when 1 then 1 when 2 then 0 when 3 then 1 else 0 end) as sent,
(
select count(*) > 0
from
we_group_member wgm
left join we_group_code_actual ac on ac.chat_id = wgm.chat_id and ac.del_flag = 0
where ac.group_code_id = task.group_code_id and wgm.user_id = wgmsr.external_userid
) as inGroup
from
we_group_message_send_result wgmsr
left join we_customer wc on wc.external_userid = wgmsr.external_userid
left join we_pres_tag_group task on task.message_template_id = wgmsr.msg_template_id
where
wgmsr.del_flag = 0
and task.task_id = #{taskId}
<if test="customerName != null and customerName != ''">
and wc.name like concat('%', #{customerName}, '%')
</if>
<if test="(sent != null and sent != '') or sent == 0">
and (case wgmsr.`status` when 0 then 0 when 1 then 1 when 2 then 0 when 3 then 1 else 0 end) = #{sent}
</if>
<if test="(inGroup != null and inGroup != '') or inGroup == 0">
and (
select count(*) > 0
from
we_group_member wgm
left join we_group_code_actual ac on ac.chat_id = wgm.chat_id and ac.del_flag = 0
where ac.group_code_id = task.group_code_id and wgm.user_id = wgmsr.external_userid
) = #{inGroup}
</if>
<select id="getAllExternalIdByTaskId" parameterType="Long" resultType="String">
SELECT DISTINCT
wc.external_userid
FROM
we_customer wc
LEFT JOIN we_group_member wgm ON wgm.user_id = wc.external_userid
LEFT JOIN we_group wg ON wg.chat_id = wgm.chat_id
LEFT JOIN we_group_code_actual wgca ON wgca.chat_id = wg.chat_id
LEFT JOIN we_pres_tag_group wptg ON wptg.group_code_id = wgca.group_code_id
WHERE
wptg.task_id = #{taskId}
</select> </select>
<select id="selectStatInfoByTaskId" parameterType="Long" resultMap="WePresTagGroupTaskStatResult"> <select id="singleSendResultList" parameterType="com.linkwechat.wecom.domain.WePresTagGroupTaskStat" resultType="com.linkwechat.wecom.domain.WePresTagGroupTaskStat">
SELECT SELECT DISTINCT
wc.`name`, cu.`name` AS customerName,
0 AS is_sent,
( (
SELECT SELECT count(*) > 0
count(1) > 0 FROM we_group_member wgm
FROM LEFT JOIN we_group_code_actual ac ON ac.chat_id = wgm.chat_id AND ac.del_flag = 0
we_customer wc1 LEFt JOIn we_pres_tag_group task On ac.group_code_id = task.group_code_id
LEFT JOIN we_group_member wgm ON wgm.user_id = wc1.external_userid
LEFT JOIN we_group wg ON wg.chat_id = wgm.chat_id
LEFT JOIN we_group_code_actual wgca ON wgca.chat_id = wg.chat_id
LEFT JOIN we_pres_tag_group wptg1 ON wptg1.group_code_id = wgca.group_code_id
WHERE WHERE
wc1.external_userid = wptgs.external_userid task.task_id = st.task_id AND wgm.user_id = st.external_userid
) AS is_in_group ) AS inGroup,
st.sent
FROM FROM
we_pres_tag_group_stat wptgs we_pres_tag_group_stat st
LEFT JOIN we_pres_tag_group wptg ON wptgs.task_id = wptg.task_id left join we_customer cu on cu.external_userid = st.external_userid and cu.del_flag = 0
LEFT JOIN we_customer wc ON wc.external_userid = wptgs.external_userid where st.del_flag = 0 and st.task_id = #{taskId}
<if test="customerName != null and customerName != ''">
and cu.`name` like concat('%', #{customerName}, '%')
</if>
<if test="(sent != null and sent != '') or sent == 0">
and st.sent = #{sent}
</if>
<if test="(inGroup != null and inGroup != '') or inGroup == 0">
and (
SELECT count(*) > 0
FROM we_group_member wgm
LEFT JOIN we_group_code_actual ac ON ac.chat_id = wgm.chat_id AND ac.del_flag = 0
LEFt JOIn we_pres_tag_group task On ac.group_code_id = task.group_code_id
WHERE WHERE
wptgs.task_id = #{taskId} task.task_id = st.task_id AND wgm.user_id = st.external_userid
) = #{inGroup}
</if>
</select> </select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!