Commit 4bc9ccc9 by 徐高华

社群群发

parent ce9619ac
...@@ -6,7 +6,10 @@ public enum PlanSendStatusEnum { ...@@ -6,7 +6,10 @@ public enum PlanSendStatusEnum {
TO_BE_SEND(1, "待发送"), TO_BE_SEND(1, "待发送"),
SENDED(2, "禁用"); SENDED(2, "已发送"),
GIVE_UP(3, "放弃");
private int code; private int code;
private String name; private String name;
......
...@@ -12,10 +12,11 @@ import com.gic.enterprise.api.service.EnterpriseService; ...@@ -12,10 +12,11 @@ import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.haoban.manage.api.dto.ContentMaterialDTO; import com.gic.haoban.manage.api.dto.ContentMaterialDTO;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO; import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.dto.chat.*; import com.gic.haoban.manage.api.dto.chat.*;
import com.gic.haoban.manage.api.dto.qdto.chat.GroupChatSearchQDTO;
import com.gic.haoban.manage.api.dto.qdto.chat.OwnerSearchQDTO; import com.gic.haoban.manage.api.dto.qdto.chat.OwnerSearchQDTO;
import com.gic.haoban.manage.api.qdto.StaffSendResultQDTO; import com.gic.haoban.manage.api.qdto.StaffSendResultQDTO;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanStaffClerkRelationMapper; import com.gic.haoban.manage.service.dao.mapper.TabHaobanStaffClerkRelationMapper;
import com.gic.haoban.manage.service.dao.mapper.chat.GroupChatOwnerMapper; import com.gic.haoban.manage.service.dao.mapper.chat.*;
import com.gic.haoban.manage.service.service.content.impl.GroupMessageServiceImpl; import com.gic.haoban.manage.service.service.content.impl.GroupMessageServiceImpl;
import com.gic.haoban.manage.service.util.StreamUtils; import com.gic.haoban.manage.service.util.StreamUtils;
import com.gic.thirdparty.cloudfile.CloudFileUtil; import com.gic.thirdparty.cloudfile.CloudFileUtil;
...@@ -55,9 +56,6 @@ import com.gic.haoban.manage.api.enums.PendingTaskTypeEnum; ...@@ -55,9 +56,6 @@ import com.gic.haoban.manage.api.enums.PendingTaskTypeEnum;
import com.gic.haoban.manage.api.enums.chat.PlanSendStatusEnum; import com.gic.haoban.manage.api.enums.chat.PlanSendStatusEnum;
import com.gic.haoban.manage.service.config.Config; import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.dao.mapper.StaffMapper; import com.gic.haoban.manage.service.dao.mapper.StaffMapper;
import com.gic.haoban.manage.service.dao.mapper.chat.GroupChatPlanLogMapper;
import com.gic.haoban.manage.service.dao.mapper.chat.GroupChatPlanMapper;
import com.gic.haoban.manage.service.dao.mapper.chat.GroupChatPlanOwnerLogMapper;
import com.gic.haoban.manage.service.entity.TabHaobanStaff; import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.gic.haoban.manage.service.entity.chat.TabGroupChatPlan; import com.gic.haoban.manage.service.entity.chat.TabGroupChatPlan;
import com.gic.haoban.manage.service.entity.chat.TabGroupChatPlanLog; import com.gic.haoban.manage.service.entity.chat.TabGroupChatPlanLog;
...@@ -119,6 +117,8 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService { ...@@ -119,6 +117,8 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
private GroupChatOwnerMapper groupChatOwnerMapper ; private GroupChatOwnerMapper groupChatOwnerMapper ;
@Autowired @Autowired
private TabHaobanStaffClerkRelationMapper tabHaobanStaffClerkRelationMapper ; private TabHaobanStaffClerkRelationMapper tabHaobanStaffClerkRelationMapper ;
@Autowired
private GroupChatMapper groupChatMapper ;
private static GicMQClient mqClient = GICMQClientUtil.getClientInstance(); private static GicMQClient mqClient = GICMQClientUtil.getClientInstance();
...@@ -532,6 +532,7 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService { ...@@ -532,6 +532,7 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
int failCount = 0; int failCount = 0;
List<TabGroupChatPlanLog> addList = new ArrayList<>(); List<TabGroupChatPlanLog> addList = new ArrayList<>();
boolean endFlag = false; boolean endFlag = false;
List<Long> doneGroupChatIdList = new ArrayList<>() ;
for (QywxSendMessageResultDTO item : list) { for (QywxSendMessageResultDTO item : list) {
TabGroupChatPlanLog entity = new TabGroupChatPlanLog(); TabGroupChatPlanLog entity = new TabGroupChatPlanLog();
Date sendTime = item.getSendTime(); Date sendTime = item.getSendTime();
...@@ -552,6 +553,7 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService { ...@@ -552,6 +553,7 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
continue; continue;
} }
entity.setGroupChatId(chat.getGroupChatId()); entity.setGroupChatId(chat.getGroupChatId());
doneGroupChatIdList.add(chat.getGroupChatId()) ;
// 企微返回成功 // 企微返回成功
// 0-未发送 1-已发送 2-因客户不是好友导致发送失败 3-因客户已经收到其他群发消息导致发送失败 // 0-未发送 1-已发送 2-因客户不是好友导致发送失败 3-因客户已经收到其他群发消息导致发送失败
if (item.getStatus() == 1) { if (item.getStatus() == 1) {
...@@ -572,9 +574,39 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService { ...@@ -572,9 +574,39 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
entity.setSendTime(sendTime); entity.setSendTime(sendTime);
addList.add(entity); addList.add(entity);
} }
// 查询群主的所有群
GroupChatSearchQDTO chatQDTO = new GroupChatSearchQDTO() ;
chatQDTO.setWxEnterpriseId(wxEnterpriseId);
chatQDTO.setEnterpriseId(enterpriseId);
chatQDTO.setStaffId(staffId);
chatQDTO.setStatus(0);
chatQDTO.setGicFlag(1);
List<GroupChatDTO> groupChatDTOList = this.groupChatMapper.list(chatQDTO);
if(CollectionUtils.isNotEmpty(groupChatDTOList)) {
for(GroupChatDTO chatDTO : groupChatDTOList) {
Long groupChatId = chatDTO.getGroupChatId();
if(!doneGroupChatIdList.contains(groupChatId)) {
logger.info("放弃执行的群={}",groupChatId);
TabGroupChatPlanLog entity = new TabGroupChatPlanLog();
entity.setSendStatus(PlanSendStatusEnum.GIVE_UP.getCode());
entity.setGroupChatId(groupChatId);
entity.setLogId(UniqueIdUtils.uniqueLong());
entity.setPlanId(ownerLog.getPlanId());
entity.setOwnLogId(ownerLog.getOwnerLogId());
entity.setWxEnterpriseId(wxEnterpriseId);
entity.setEnterpriseId(enterpriseId);
entity.setStaffId(staffId);
entity.setSendTime(new Date());
failCount = failCount+1 ;
addList.add(entity) ;
}
}
}
if (CollectionUtils.isNotEmpty(addList)) { if (CollectionUtils.isNotEmpty(addList)) {
this.groupChatPlanLogMapper.batchInsert(addList); this.groupChatPlanLogMapper.batchInsert(addList);
} }
// 更新统计数量、状态 // 更新统计数量、状态
if (!endFlag) { if (!endFlag) {
this.groupChatPlanOwnerLogService.updateSendCount(ownerLog.getOwnerLogId(), sendCount, this.groupChatPlanOwnerLogService.updateSendCount(ownerLog.getOwnerLogId(), sendCount,
......
...@@ -98,6 +98,7 @@ public class GroupChatPlanController { ...@@ -98,6 +98,7 @@ public class GroupChatPlanController {
qdto.setEnterpriseId(qo.getEnterpriseId()); qdto.setEnterpriseId(qo.getEnterpriseId());
qdto.setSearchParams(qo.getChatName()); qdto.setSearchParams(qo.getChatName());
qdto.setStatus(0); qdto.setStatus(0);
qdto.setGicFlag(1);
ServiceResponse<Page<GroupChatDTO>> page = this.groupChatApiService.listPage(qdto, qo); ServiceResponse<Page<GroupChatDTO>> page = this.groupChatApiService.listPage(qdto, qo);
return RestResponse.successResult(page.getResult()); return RestResponse.successResult(page.getResult());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment