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

1 parent c66038b5
Showing 18 changed files with 431 additions and 264 deletions
......@@ -83,10 +83,10 @@
<!-- <dependency>-->
<!-- <groupId>io.github.leejoker</groupId>-->
<!-- <artifactId>linkwechat-nacos-starter</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>io.github.leejoker</groupId>
<artifactId>linkwechat-nacos-starter</artifactId>
</dependency>
......
......@@ -27,16 +27,16 @@ import java.util.List;
public class WeCommunityH5Controller extends BaseController {
@Autowired
private IWePresTagGroupTaskService tagGroupTaskService;
IWePresTagGroupTaskService tagGroupTaskService;
@Autowired
private IWeGroupSopService sopService;
IWeGroupSopService sopService;
@Autowired
private IWeCommunityKeywordToGroupService keywordToGroupService;
IWeCommunityKeywordToGroupService keywordToGroupService;
@Autowired
private ISysUserService userService;
ISysUserService userService;
/**
* 获取任务对应的执行人列表
......@@ -65,8 +65,8 @@ public class WeCommunityH5Controller extends BaseController {
AjaxResult res = AjaxResult.success();
if (type.equals(CommunityTaskType.TAG.getType())) {
// 老客标签建群数据
res.put("todo", tagGroupTaskService.getEmplTaskList(emplId, false));
res.put("done", tagGroupTaskService.getEmplTaskList(emplId, true));
res.put("todo", tagGroupTaskService.getFollowerTaskList(emplId, 0));
res.put("done", tagGroupTaskService.getFollowerTaskList(emplId, 1));
} else if (type.equals(CommunityTaskType.SOP.getType())) {
// 群SOP数据
res.put("todo", sopService.getEmplTaskList(emplId, false));
......@@ -75,10 +75,10 @@ public class WeCommunityH5Controller extends BaseController {
// 全部数据
List todoList = new ArrayList();
List doneList = new ArrayList();
todoList.addAll(tagGroupTaskService.getEmplTaskList(emplId, false));
todoList.addAll(tagGroupTaskService.getFollowerTaskList(emplId, 0));
todoList.addAll(sopService.getEmplTaskList(emplId, false));
res.put("todo", todoList);
doneList.addAll(tagGroupTaskService.getEmplTaskList(emplId, true));
doneList.addAll(tagGroupTaskService.getFollowerTaskList(emplId, 1));
doneList.addAll(sopService.getEmplTaskList(emplId, true));
res.put("done", doneList);
}
......@@ -99,11 +99,11 @@ public class WeCommunityH5Controller extends BaseController {
@GetMapping("/changeStatus")
public AjaxResult changeStatus(@RequestParam("taskId") Long taskId, @RequestParam("emplId") String emplId, @RequestParam("type") Integer type) {
if (type.equals(0)) {
return toAjax(tagGroupTaskService.updateEmplTaskStatus(taskId, emplId));
return toAjax(tagGroupTaskService.updateFollowerTaskStatus(taskId, emplId));
} else {
return toAjax(sopService.updateChatSopStatus(taskId, emplId));
}
}
/**
......
......@@ -2,50 +2,49 @@ package com.linkwechat.web.controller.wecom;
import com.linkwechat.common.constant.HttpStatus;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.page.TableDataInfo;
import com.linkwechat.common.utils.SecurityUtils;
import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.common.utils.bean.BeanUtils;
import com.linkwechat.wecom.domain.WePresTagGroupTask;
import com.linkwechat.wecom.domain.dto.WePresTagGroupTaskDto;
import com.linkwechat.wecom.domain.vo.WePresTagGroupTaskStatVo;
import com.linkwechat.wecom.domain.WePresTagGroupTaskStat;
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.IWeGroupCodeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
@Api("老客标签建群接口")
@RestController
@RequestMapping(value = "/wecom/communityPresTagGroup")
public class WeCommunityPresTagGroupController extends BaseController {
@Autowired
private IWePresTagGroupTaskService taskService;
IWePresTagGroupTaskService taskService;
@Autowired
private IWeGroupCodeService groupCodeService;
/**
* 获取老客标签建群列表数据
*/
// @PreAuthorize("@ss.hasPermi('wecom:communitytagGroup: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 = "sendType", required = false) Integer sendType,
@RequestParam(value = "createBy", required = false) String createBy,
@RequestParam(value = "beginTime", required = false) String beginTime,
@RequestParam(value = "endTime", required = false) String endTime) {
startPage();
List<WePresTagGroupTaskVo> wePresTagGroupTaskVoList = taskService.selectTaskList(taskName, sendType, createBy, beginTime, endTime);
return getDataTable(wePresTagGroupTaskVoList);
List<WePresTagTaskListVO> result = taskService.selectTaskList(taskName, sendType, createBy, beginTime, endTime);
return getDataTable(result);
}
/**
......@@ -53,28 +52,16 @@ public class WeCommunityPresTagGroupController extends BaseController {
*/
// @PreAuthorize("@ss.hasPermi('wecom:communitytagGroup:add')")
@PostMapping
public AjaxResult addTask(@RequestBody @Validated WePresTagGroupTaskDto wePresTagGroupTaskDto) {
if (null == groupCodeService.getById(wePresTagGroupTaskDto.getGroupCodeId())) {
return AjaxResult.error(HttpStatus.NOT_FOUND, "群活码不存在");
}
WePresTagGroupTask task = new WePresTagGroupTask();
BeanUtils.copyProperties(wePresTagGroupTaskDto, task);
@ApiOperation(value = "新建老客标签建群任务", httpMethod = "POST")
public AjaxResult add(@RequestBody @Validated WePresTagGroupTask task) {
// 检测任务名是否可用
if (taskService.isNameOccupied(task)) {
return AjaxResult.error("任务名已存在");
}
task.setCreateBy(SecurityUtils.getUsername());
List<String> tagList = wePresTagGroupTaskDto.getTagList();
List<String> scopeList = wePresTagGroupTaskDto.getScopeList();
int affectedRows = taskService.add(task, tagList, scopeList);
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);
}
int affectedRows = taskService.add(task);
// 再发送消息
if (affectedRows > 0) taskService.sendMessage(task);
return toAjax(affectedRows);
}
......@@ -83,7 +70,8 @@ public class WeCommunityPresTagGroupController extends BaseController {
*/
// @PreAuthorize("@ss.hasPermi('wecom:communitytagGroup:query')")
@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);
if (StringUtils.isNull(taskVo)) {
return AjaxResult.error(HttpStatus.NOT_FOUND, "群活码不存在");
......@@ -96,11 +84,15 @@ public class WeCommunityPresTagGroupController extends BaseController {
*/
// @PreAuthorize("@ss.hasPermi('wecom:communitytagGroup:edit')")
@PutMapping(path = "/{id}")
public AjaxResult updateTask(@PathVariable("id") Long id, @RequestBody @Validated WePresTagGroupTaskDto wePresTagGroupTaskDto) {
if (null == groupCodeService.getById(wePresTagGroupTaskDto.getGroupCodeId())) {
return AjaxResult.error(HttpStatus.NOT_FOUND, "群活码不存在");
}
return toAjax(taskService.updateTask(id, wePresTagGroupTaskDto));
@ApiOperation(value = "更新任务信息", httpMethod = "PUT")
public AjaxResult update(@PathVariable("id") Long id, @RequestBody @Validated WePresTagGroupTask task) {
// 保存新任务
task.setTaskId(id);
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 {
*/
// @PreAuthorize("@ss.hasPermi('wecom:communitytagGroup:remove')")
@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));
}
......@@ -117,16 +110,17 @@ public class WeCommunityPresTagGroupController extends BaseController {
*/
// @PreAuthorize("@ss.hasPermi('wecom:communitytagGroup:query')")
@GetMapping(path = "/stat/{id}")
public TableDataInfo<List<WePresTagGroupTaskStatVo>> getStatInfo(
public TableDataInfo<List<WePresTagGroupTaskStat>> getStatInfo(
@PathVariable("id") Long id,
@RequestParam(value = "customerName", required = false) String customerName,
@RequestParam(value = "isInGroup", required = false) Integer isInGroup,
@RequestParam(value = "isSent", required = false) Integer isSent
) {
WePresTagGroupTask task = taskService.getById(id);
startPage();
List<WePresTagGroupTaskStatVo> statVoList = taskService.getStatByTaskId(id);
return getDataTable(statVoList);
List<WePresTagGroupTaskStat> stats = taskService.getTaskStat(id, customerName, isInGroup, isSent, task.getSendType());
return getDataTable(stats);
}
......
......@@ -411,4 +411,10 @@ public class WeConstans {
* 群发消息任务开关
*/
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;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.linkwechat.common.core.domain.BaseEntity;
import com.linkwechat.common.utils.SnowFlakeUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
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
@EqualsAndHashCode(callSuper = true)
@TableName("we_pres_tag_group")
......@@ -19,57 +27,104 @@ public class WePresTagGroupTask extends BaseEntity {
/**
*主键ID
*/
@ApiModelProperty("id")
@TableId
private Long taskId = SnowFlakeUtil.nextId();
/**
* 任务名称
*/
@ApiModelProperty("任务名")
@NotNull(message = "任务名称不能为空")
private String taskName;
/**
* 加群引导语
*/
@ApiModelProperty("加群引导语")
@Size(max = 64, message = "引导与不能超过64字符")
@NotBlank(message = "引导语不能为空")
private String welcomeMsg;
/**
* 发送方式 0: 企业群发 1:个人群发
*/
@ApiModelProperty("加群引导语")
@NotNull(message = "发送方式不能为空")
private Integer sendType;
/**
* 群活码id
*/
@ApiModelProperty("群活码id")
@NotNull(message = "活码不能为空")
private Long groupCodeId;
/**
* 发送范围 0: 全部客户 1:部分客户
*/
@ApiModelProperty("发送范围 0: 全部客户 1:部分客户")
private Integer sendScope;
/**
* 发送性别 0: 全部 1: 男 2: 女 3:未知
*/
@ApiModelProperty("发送性别 0: 全部 1: 男 2: 女 3:未知")
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")
private Integer delFlag;
@ApiModelProperty(value = "逻辑删除字段", hidden = true)
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;
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.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* 老客户标签建群任务使用人对象
*/
@ApiModel("老客户标签建群跟进者")
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName("we_pres_tag_group_scope")
public class WePresTagGroupTaskScope {
public class WePresTagGroupTaskScope extends BaseEntity {
private static final long serialVersionUID = 86648978618184060L;
/**
* 老客户标签建群任务id
*/
@ApiModelProperty("老客户标签建群任务id")
private Long taskId;
/**
* 任务目标员工id
*/
@ApiModelProperty("任务目标员工id")
private String weUserId;
/**
* 是否已处理
*/
private boolean isDone;
@ApiModelProperty(value = "有效标识", hidden = true)
@JsonIgnore
private Integer delFlag = 0;
}
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.EqualsAndHashCode;
import com.linkwechat.common.core.domain.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.NoArgsConstructor;
/**
* 老客户标签建群客户统计
* 老客户标签建群客户统计(用于个人群发类型的统计)
*/
@ApiModel("老客标签建群发送统计对象")
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@TableName("we_pres_tag_group_stat")
public class WePresTagGroupTaskStat extends BaseEntity {
private static final long serialVersionUID = 504772877084507165L;
/**
* 老客户标签建群任务id
*/
@ApiModelProperty("老客户标签建群任务id")
private Long taskId;
/**
* 客户id
* 客户名称
*/
@ApiModelProperty("客户名称")
@TableField(exist = false)
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;
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.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* 老客标签建群任务标签关联对象
*/
@ApiModel("老客标签建群标签")
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName("we_pres_tag_group_tag")
public class WePresTagGroupTaskTag {
public class WePresTagGroupTaskTag extends BaseEntity {
private static final long serialVersionUID = 4859443233276436220L;
/**
* 老客建群任务id
*/
@ApiModelProperty("老客建群任务id")
private Long taskId;
/**
* 标签id
*/
@ApiModelProperty("标签id")
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;
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.WePresTagTaskListVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WePresTagGroupTask;
import org.springframework.security.core.parameters.P;
import java.util.List;
......@@ -16,19 +18,22 @@ import java.util.List;
public interface WePresTagGroupTaskMapper extends BaseMapper<WePresTagGroupTask> {
/**
* 添加新任务
* @param task 老客标签建群任务
* 根据条件查询老客标签建群任务
*
* @param taskName 任务名称
* @param createBy 创建人
* @param beginTime 开始时间
* @param endTime 结束时间
* @param sendType 发送方式
* @return 结果
*/
int insertTask(WePresTagGroupTask task);
List<WePresTagTaskListVO> selectListVO(@Param("taskName") String taskName,
@Param("sendType") Integer sendType,
@Param("createBy") String createBy,
@Param("beginTime") String beginTime,
@Param("endTime") String endTime);
/**
* 更新任务
* @param task 建群任务信息
* @return 结果
*/
int updateTask(WePresTagGroupTask task);
/**
* 获取老客户标签建群任务
*
* @param taskId 任务id
......@@ -36,46 +41,54 @@ public interface WePresTagGroupTaskMapper extends BaseMapper<WePresTagGroupTask>
*/
WePresTagGroupTaskVo selectTaskById(Long taskId);
/**
* 根据条件查询老客标签建群任务
* 获取某员工的任务
*
* @param taskName 任务名称
* @param createBy 创建人
* @param beginTime 开始时间
* @param endTime 结束时间
* @param sendType 发送方式
* @param followerId 员工id
* @param isDone 已完成的还是待处理
* @return 结果
*/
List<WePresTagGroupTaskVo> selectTaskList(
@Param("taskName") String taskName,
@Param("sendType") Integer sendType,
@Param("createBy") String createBy,
@Param("beginTime") String beginTime,
@Param("endTime") String endTime
);
List<WePresTagGroupTaskVo> getTaskListByFollowerId(@Param("followerId") String followerId, @Param("isDone") Integer isDone);
/**
* 获取某员工的任务
* 获取指定条件的外部联系人id,且需要排除已经在群的客户
*
* @param emplId 员工id
* @param isDone 已完成的还是待处理
* @return 结果
* @param taskId 标签建群任务id
* @return 客户的external_userids字段值数组
*/
List<WePresTagGroupTaskVo> getTaskListByEmplId(@Param("emplId") String emplId, @Param("isDone") boolean isDone);
List<WeCustomer> selectTaskExternalIds(@Param("taskId") Long taskId);
/**
* 根据task获取员工信息
* @param task
* @return
* 获取指定条件的外部联系人id,且需要排除已经在群的客户
*
* @param taskId 标签建群任务id
* @return 客户的external_userids字段值数组
*/
List<SenderInfo> selectSenderInfo(@Param("taskId") Long taskId);
/**
* 获取指定条件的员工id
*
* @param taskId 标签建群任务id
* @return 获取目标客户对应员工的id数组
*/
List<String> selectStaffList(WePresTagGroupTask task);
List<String> selectTaskFollowerIds(@Param("taskId") Long taskId);
List<String> selectExternalUserIds(
@Param("taskId") Long taskId,
@Param("hasScope") boolean hasScope,
@Param("hasTag") boolean hasTag,
@Param("gender") Integer gender,
@Param("beginTime") String beginTime,
@Param("endTime") String endTime
);
/**
* 根据任务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;
import java.util.List;
@Mapper
@Repository
public interface WePresTagGroupTaskStatMapper extends BaseMapper<WePresTagGroupTaskStat> {
int batchSave(List<WePresTagGroupTaskStat> stats);
/**
* 根据 老客标签建群任务id及附属相关属性条件获取任务对应的客户统计
*
* @param taskId 任务id
* @return 客户统计列表
* 获取老客标签建群任务的消息发送结果
* @param stat 过滤条件
* @return 发送结果列表
*/
List<WePresTagGroupTaskStatVo> selectStatInfoByTaskId(@Param("taskId") Long taskId);
List<WePresTagGroupTaskStat> cropSendResultList(WePresTagGroupTaskStat stat);
/**
* 通过taskId获取所有外部联系人id
*
* @param taskId 老客标签建群任务id
* @return 结果
* 获取老客标签建群任务的消息发送结果
* @param stat 过滤条件
* @return 发送结果列表
*/
List<String> getAllExternalIdByTaskId(Long taskId);
List<WePresTagGroupTaskStat> singleSendResultList(WePresTagGroupTaskStat stat);
}
package com.linkwechat.wecom.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WePresTagGroupTask;
import com.linkwechat.wecom.domain.WeTag;
import com.linkwechat.wecom.domain.dto.WePresTagGroupTaskDto;
import com.linkwechat.wecom.domain.WePresTagGroupTaskStat;
import com.linkwechat.wecom.domain.vo.WeCommunityTaskEmplVo;
import com.linkwechat.wecom.domain.vo.WePresTagGroupTaskVo;
import com.linkwechat.wecom.domain.vo.WePresTagGroupTaskStatVo;
import org.apache.ibatis.annotations.Param;
import com.linkwechat.wecom.domain.vo.WePresTagTaskListVO;
import java.util.List;
/**
* 社区运营 老客户标签建群 相关逻辑
*/
public interface IWePresTagGroupTaskService {
public interface IWePresTagGroupTaskService extends IService<WePresTagGroupTask> {
/**
* 添加新标签建群任务
*
* @param task 建群任务本体信息
* @param tagIdList 标签列表
* @param emplIdList 员工列表
* @param task 建群任务本体信息
* @return 结果
*/
int add(WePresTagGroupTask task, List<String> tagIdList, List<String> emplIdList);
int add(WePresTagGroupTask task);
/**
* 根据条件查询任务列表
......@@ -35,7 +32,7 @@ public interface IWePresTagGroupTaskService {
* @param endTime 结束时间
* @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获取老客标签建群任务
......@@ -56,20 +53,22 @@ public interface IWePresTagGroupTaskService {
/**
* 更新老客户标签建群任务
*
* @param taskId 待更新任务id
* @param wePresTagGroupTaskDto 更新数据
* @param task 待更新任务
* @return 更新条数
*/
int updateTask(Long taskId, WePresTagGroupTaskDto wePresTagGroupTaskDto);
int updateTask(WePresTagGroupTask task);
/**
* 通过老客标签建群id获取其统计信息
* 根据查询条件获取任务的统计结果
*
* @param taskId 任务id
* @return 统计信息
* @param id 任务id
* @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获取对应员工信息列表
......@@ -80,37 +79,29 @@ public interface IWePresTagGroupTaskService {
List<WeCommunityTaskEmplVo> getScopeListByTaskId(Long taskId);
/**
* 根据任务id获取对应标签信息列表
*
* @param taskId 任务id
* @return 结果
*/
List<WeTag> getTagListByTaskId(Long taskId);
/**
* 获取员工建群任务信息
*
* @param emplId 员工id
* @param isDone 是否已处理
* @return 结果
*/
List<WePresTagGroupTaskVo> getEmplTaskList(String emplId, boolean isDone);
List<WePresTagGroupTaskVo> getFollowerTaskList(String emplId, Integer isDone);
/**
* 员工发送信息后,变更其任务状态为 "完成"
* 员工在H5任务页面发送信息后,变更其任务状态为 "完成"
*
* @param taskId 任务id
* @param emplId 员工id
* @param taskId 任务id
* @param followerId 跟进者id
* @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 {
*/
boolean isNameOccupied(WePresTagGroupTask task);
List<String> selectExternalUserIds(
Long taskId,
boolean hasScope,
boolean hasTag,
Integer gender,
String beginTime,
String endTime
);
/**
* 获取外部联系人id, 用于企业群发的 external_userid参数
*
* @param taskId 任务id
* @return 外部联系人id
*/
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;
import com.linkwechat.common.utils.spring.SpringUtils;
import com.linkwechat.wecom.annotation.SynchRecord;
import com.linkwechat.wecom.client.WeCustomerClient;
import com.linkwechat.wecom.client.WeMsgAuditClient;
import com.linkwechat.wecom.client.WeUserClient;
import com.linkwechat.wecom.constants.SynchRecordConstants;
import com.linkwechat.wecom.domain.WeCustomerAddUser;
......
......@@ -4,52 +4,81 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<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">
delete from we_pres_tag_group_stat where task_id = #{taskId}
</delete>
<insert id="batchSave">
insert into we_pres_tag_group_stat (task_id, user_id, external_userid, sent, create_by, create_time) values
<foreach item="item" index="index" collection="list" separator=",">
(#{item.taskId}, #{item.userId}, #{item.externalUserId}, #{item.sent}, #{item.createBy}, #{item.createTime})
</foreach>
</insert>
<select id="getAllExternalIdByTaskId" parameterType="Long" resultType="String">
<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>
<select id="singleSendResultList" parameterType="com.linkwechat.wecom.domain.WePresTagGroupTaskStat" resultType="com.linkwechat.wecom.domain.WePresTagGroupTaskStat">
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
cu.`name` AS customerName,
(
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
wptg.task_id = #{taskId}
</select>
<select id="selectStatInfoByTaskId" parameterType="Long" resultMap="WePresTagGroupTaskStatResult">
SELECT
wc.`name`,
0 AS is_sent,
(
SELECT
count(1) > 0
FROM
we_customer wc1
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
wc1.external_userid = wptgs.external_userid
) AS is_in_group
task.task_id = st.task_id AND wgm.user_id = st.external_userid
) AS inGroup,
st.sent
FROM
we_pres_tag_group_stat wptgs
LEFT JOIN we_pres_tag_group wptg ON wptgs.task_id = wptg.task_id
LEFT JOIN we_customer wc ON wc.external_userid = wptgs.external_userid
WHERE
wptgs.task_id = #{taskId}
we_pres_tag_group_stat st
left join we_customer cu on cu.external_userid = st.external_userid and cu.del_flag = 0
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
task.task_id = st.task_id AND wgm.user_id = st.external_userid
) = #{inGroup}
</if>
</select>
</mapper>
\ 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!