|
@@ -3,12 +3,14 @@ package com.fs.qw.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
+import com.fs.common.core.redis.RedisCache;
|
|
|
import com.fs.common.utils.DateUtils;
|
|
|
import com.fs.company.service.ICompanyConfigService;
|
|
|
-import com.fs.qw.domain.QwCompany;
|
|
|
-import com.fs.qw.domain.QwGroupMsg;
|
|
|
-import com.fs.qw.domain.QwGroupMsgItem;
|
|
|
-import com.fs.qw.domain.QwGroupMsgUser;
|
|
|
+import com.fs.course.domain.FsCourseLink;
|
|
|
+import com.fs.course.domain.FsCourseRealLink;
|
|
|
+import com.fs.course.mapper.FsCourseLinkMapper;
|
|
|
+import com.fs.course.param.FsCourseLinkCreateParam;
|
|
|
+import com.fs.qw.domain.*;
|
|
|
import com.fs.qw.mapper.QwCompanyMapper;
|
|
|
import com.fs.qw.mapper.QwGroupMsgItemMapper;
|
|
|
import com.fs.qw.mapper.QwGroupMsgMapper;
|
|
@@ -16,10 +18,7 @@ import com.fs.qw.mapper.QwGroupMsgUserMapper;
|
|
|
import com.fs.qw.param.QwCountCustomerParam;
|
|
|
import com.fs.qw.param.QwGroupMsgDetailsParam;
|
|
|
import com.fs.qw.param.QwGroupMsgParam;
|
|
|
-import com.fs.qw.service.IQwExternalContactService;
|
|
|
-import com.fs.qw.service.IQwGroupMsgService;
|
|
|
-import com.fs.qw.service.IQwGroupchatStatisticService;
|
|
|
-import com.fs.qw.service.IQwUserbehaviorDataService;
|
|
|
+import com.fs.qw.service.*;
|
|
|
import com.fs.qw.vo.QwGroupMsgDetailsVO;
|
|
|
import com.fs.qw.vo.QwGroupMsgVO;
|
|
|
import com.fs.qwApi.Result.*;
|
|
@@ -30,6 +29,9 @@ import com.fs.qwApi.param.QwMsgTemplate;
|
|
|
import com.fs.qwApi.service.QwApiService;
|
|
|
import com.fs.sop.service.IQwSopService;
|
|
|
import com.fs.voice.utils.StringUtil;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -38,10 +40,11 @@ import java.io.File;
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.net.URL;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.ZoneId;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+import static com.fs.course.utils.LinkUtil.generateRandomStringWithLock;
|
|
|
|
|
|
/**
|
|
|
* 客户群发记录主Service业务层处理
|
|
@@ -52,6 +55,11 @@ import java.util.List;
|
|
|
@Service
|
|
|
public class QwGroupMsgServiceImpl implements IQwGroupMsgService
|
|
|
{
|
|
|
+
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(QwGroupMsgServiceImpl.class);
|
|
|
+
|
|
|
+ private static final String miniappRealLink = "/pages_course/video.html?course=";
|
|
|
+
|
|
|
@Autowired
|
|
|
private QwGroupMsgMapper qwGroupMsgMapper;
|
|
|
|
|
@@ -71,6 +79,9 @@ public class QwGroupMsgServiceImpl implements IQwGroupMsgService
|
|
|
private IQwExternalContactService qwExternalContactService;
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IQwGroupMsgUserService qwGroupMsgUserService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private QwWelcomeServiceImpl qwWelcomeService;
|
|
|
|
|
@@ -85,6 +96,16 @@ public class QwGroupMsgServiceImpl implements IQwGroupMsgService
|
|
|
|
|
|
@Autowired
|
|
|
private IQwGroupchatStatisticService qwGroupchatStatisticService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RedisCache redisCache;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FsCourseLinkMapper fsCourseLinkMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IQwCompanyService iQwCompanyService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询客户群发记录主
|
|
|
*
|
|
@@ -227,320 +248,517 @@ public class QwGroupMsgServiceImpl implements IQwGroupMsgService
|
|
|
}
|
|
|
|
|
|
|
|
|
-// if (qwGroupMsgParam.getMsgType()==3){
|
|
|
-// return R.error("暂时无法上传小程序");
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
qwGroupMsg.setCorpId(qwGroupMsgParam.getCorpId());
|
|
|
|
|
|
//主表存/任务类型
|
|
|
qwGroupMsg.setChatType(qwGroupMsgParam.getChatType());
|
|
|
|
|
|
- //发送这条消息文本的成员集合
|
|
|
- qwGroupMsg.setSender(userIdsSelectList.toString());
|
|
|
- qwGroupMsg.setAllowSelect(qwGroupMsgParam.getAllowSelect());
|
|
|
- qwGroupMsg.setTextContent(qwGroupMsgParam.getTextContent());
|
|
|
- qwGroupMsg.setCreateName(qwGroupMsgParam.getCreateName());
|
|
|
- qwGroupMsg.setGroupChatNames(qwGroupMsgParam.getGroupChatNames());
|
|
|
+ if (qwGroupMsgParam.getMsgType()==3){
|
|
|
+ for (String quId : userIdsSelectList) {
|
|
|
|
|
|
- //如果发送给客户群
|
|
|
- if (qwGroupMsgParam.getChatType().equals("group")){
|
|
|
+ QwUser qwUser = qwExternalContactService.getQwUserByRedis(qwGroupMsgParam.getCorpId().trim(), quId.trim());
|
|
|
|
|
|
- qwGroupMsg.setFilterCustomers(JSON.toJSONString(qwGroupMsgParam.getGroupChatNamesMap()));
|
|
|
+ if (qwUser==null||qwUser.getCompanyId()==null||qwUser.getCompanyUserId()==null){
|
|
|
+ logger.error("员工未绑定 销售公司 或 销售 请先绑定:"+quId+"|"+qwGroupMsgParam.getCorpId());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
- //定时发送时,就只存记录
|
|
|
- if (qwGroupMsgParam.getIsTimerSend()==1){
|
|
|
+ if (StringUtil.strIsNullOrEmpty(qwCompany.getMiniAppId())){
|
|
|
+ return R.error("该主体没有绑定 小程序,请联系管理员");
|
|
|
+ }
|
|
|
|
|
|
- qwGroupMsg.setIsSend(3);
|
|
|
- qwGroupMsg.setIsTimerSend(1);
|
|
|
- qwGroupMsg.setTimerSend(qwGroupMsgParam.getTimerSend());
|
|
|
- qwGroupMsg.setCreateTime(DateUtils.getNowDate());
|
|
|
+ String mediaId =(String)redisCache.getCacheObject("miniprogram:"+qwGroupMsgParam.getCorpId()+":"+qwGroupMsgParam.getCourseId());
|
|
|
+ if (StringUtil.strIsNullOrEmpty(mediaId)){
|
|
|
+ return R.error("该课程封面未上传 至企业微信,请联系管理员");
|
|
|
+ }
|
|
|
|
|
|
- //主表做记录
|
|
|
- insertRecordsGroup(qwGroupMsg,qwGroupMsgItem,qwGroupMsgParam.getCorpId(),qwCompany.getId());
|
|
|
+ String linkByMiniApp = createLinkByMiniApp(new Date(), qwGroupMsgParam.getCourseId(), qwGroupMsgParam.getVideoId(), qwUser, null, 1);
|
|
|
+
|
|
|
+ msgTemplate.setSender(quId);
|
|
|
+ msgTemplate.setMiniprogramAppid(qwCompany.getMiniAppId());
|
|
|
+ msgTemplate.setMiniprogramTitle(qwGroupMsgParam.getMiniprogramTitle());
|
|
|
+ msgTemplate.setMiniprogramPicMediaId(mediaId);
|
|
|
+ msgTemplate.setMiniprogramPage(linkByMiniApp);
|
|
|
+
|
|
|
+ qwGroupMsgItem.setMsgType(3);
|
|
|
+ qwGroupMsgItem.setMiniprogramTitle(qwGroupMsgParam.getMiniprogramTitle());
|
|
|
+ qwGroupMsgItem.setMiniprogramAppid(qwCompany.getMiniAppId());
|
|
|
+ qwGroupMsgItem.setMiniprogramPicUrl(qwGroupMsgParam.getMiniprogramPicUrl());
|
|
|
+ qwGroupMsgItem.setMiniprogramPicMediaId(mediaId);
|
|
|
+ qwGroupMsgItem.setMiniprogramPage(linkByMiniApp);
|
|
|
+
|
|
|
+
|
|
|
+ //发送这条消息文本的成员集合
|
|
|
+ qwGroupMsg.setSender(quId);
|
|
|
+ qwGroupMsg.setAllowSelect(qwGroupMsgParam.getAllowSelect());
|
|
|
+ qwGroupMsg.setTextContent(qwGroupMsgParam.getTextContent());
|
|
|
+ qwGroupMsg.setCreateName(qwGroupMsgParam.getCreateName());
|
|
|
+ qwGroupMsg.setGroupChatNames(qwGroupMsgParam.getGroupChatNames());
|
|
|
+ qwGroupMsg.setSelectType(qwGroupMsgParam.getSelectType());
|
|
|
+ //筛选出客户
|
|
|
+ QwCountCustomerParam qwCountCustomerParam = new QwCountCustomerParam();
|
|
|
+
|
|
|
+ ArrayList<String> userIdsList=new ArrayList<>();
|
|
|
+ userIdsList.add(quId);
|
|
|
+ qwCountCustomerParam.setUserIdsSelectList(userIdsList);
|
|
|
+
|
|
|
+ qwCountCustomerParam.setSelectType(qwGroupMsgParam.getSelectType());
|
|
|
+ qwCountCustomerParam.setGender(qwGroupMsgParam.getGender());
|
|
|
+ qwCountCustomerParam.setGroupChatSelectList(qwGroupMsgParam.getGroupChatSelectList());
|
|
|
+ qwCountCustomerParam.setTimeScreenCharge(qwGroupMsgParam.getTimeScreenCharge());
|
|
|
+ qwCountCustomerParam.setTagsIdsSelectList(qwGroupMsgParam.getTagsIdsSelectList());
|
|
|
+ qwCountCustomerParam.setOutTagsIdsSelectList(qwGroupMsgParam.getOutTagsIdsSelectList());
|
|
|
|
|
|
- return R.ok();
|
|
|
- }else {
|
|
|
+ //根据 条件 筛选出预计发送的客户id列表
|
|
|
+ ArrayList<String> customerList = qwExternalContactService.selectQwGroupMsgExpectCustomerList(qwCountCustomerParam, qwCompany.getCorpId());
|
|
|
|
|
|
- qwGroupMsg.setIsSend(1);
|
|
|
- qwGroupMsg.setCreateTime(DateUtils.getNowDate());
|
|
|
- //主表做记录
|
|
|
- insertRecordsGroup(qwGroupMsg,qwGroupMsgItem,qwGroupMsgParam.getCorpId(),qwCompany.getId());
|
|
|
+ qwGroupMsg.setToUserNum(customerList.size());
|
|
|
+ qwGroupMsg.setFilterCustomers(JSON.toJSONString(qwCountCustomerParam));
|
|
|
|
|
|
- }
|
|
|
+ //客户列表
|
|
|
+ msgTemplate.setExternalUseridList(customerList);
|
|
|
|
|
|
+ //发送消息文本组装
|
|
|
+ //群发任务类型()
|
|
|
+ msgTemplate.setChatType(qwGroupMsgParam.getChatType());
|
|
|
|
|
|
- //因为群发群,群主只能选择一个一个发
|
|
|
- for (String qwUserid: qwGroupMsgParam.getUserIdsSelectList()) {
|
|
|
- HashMap<String, ArrayList<String>> groupChatNamesMap = qwGroupMsgParam.getGroupChatNamesMap();
|
|
|
- if (groupChatNamesMap.containsKey(qwUserid)){
|
|
|
- ArrayList<String> arrayList = groupChatNamesMap.get(qwUserid);
|
|
|
- if (!arrayList.isEmpty()){
|
|
|
+ msgTemplate.setAllowSelect(qwGroupMsgParam.getAllowSelect() == 1 ? true : false);
|
|
|
+ msgTemplate.setTextContent(qwGroupMsgParam.getTextContent());
|
|
|
+ msgTemplate.setType(qwGroupMsgParam.getMsgType());
|
|
|
|
|
|
- msgTemplate.setChatType(qwGroupMsgParam.getChatType());
|
|
|
- msgTemplate.setSender(qwUserid);
|
|
|
- msgTemplate.setAllowSelect(qwGroupMsgParam.getAllowSelect()==1?true:false);
|
|
|
- msgTemplate.setTextContent(qwGroupMsgParam.getTextContent());
|
|
|
- msgTemplate.setType(qwGroupMsgParam.getMsgType());
|
|
|
- msgTemplate.setChatIdList(arrayList);
|
|
|
+ QwAddMsgTemplateResult qwAddMsgTemplateResult = qwApiService.addMsgTemplate(msgTemplate, qwGroupMsgParam.getCorpId());
|
|
|
|
|
|
- QwAddMsgTemplateResult qwAddMsgTemplateResult = qwApiService.addMsgTemplate(msgTemplate,qwGroupMsgParam.getCorpId());
|
|
|
+ qwGroupMsg.setMsgid(qwAddMsgTemplateResult.getMsgId() == null ? null : qwAddMsgTemplateResult.getMsgId());
|
|
|
|
|
|
- if (qwAddMsgTemplateResult.getErrCode()!=0){
|
|
|
- qwGroupMsg.setIsSend(0);
|
|
|
- qwGroupMsg.setCreateTime(DateUtils.getNowDate());
|
|
|
- //主表做记录
|
|
|
- insertRecordsGroup(qwGroupMsg,qwGroupMsgItem,qwGroupMsgParam.getCorpId(),qwCompany.getId());
|
|
|
- return R.error("成员:"+qwUserid+"/群群发消息失败"+":"+qwAddMsgTemplateResult.getErrMsg());
|
|
|
+ if (qwAddMsgTemplateResult.getErrCode() != 0 && qwAddMsgTemplateResult.getErrCode() != 41063) {
|
|
|
+
|
|
|
+ //发送失败 主表做记录
|
|
|
+ qwGroupMsg.setIsSend(0);
|
|
|
+ qwGroupMsg.setCreateTime(DateUtils.getNowDate());
|
|
|
+ //主表做记录
|
|
|
+ insertQwGroupMsgSinger(qwGroupMsg, qwGroupMsgItem, qwGroupMsgParam.getCorpId(), qwCompany.getId(), qwAddMsgTemplateResult);
|
|
|
+
|
|
|
+ logger.error("消息发送失败:" + qwAddMsgTemplateResult.getErrMsg());
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ qwGroupMsg.setFromUserNum(1);
|
|
|
+ qwGroupMsg.setIsSend(1);
|
|
|
+ qwGroupMsg.setCreateTime(DateUtils.getNowDate());
|
|
|
+
|
|
|
+ //主表做记录
|
|
|
+ int i = qwGroupMsgMapper.insertQwGroupMsg(qwGroupMsg);
|
|
|
+ if (i > 0) {
|
|
|
+
|
|
|
+ qwGroupMsgItem.setGroupMsgId(qwGroupMsg.getId());
|
|
|
+ qwGroupMsgItem.setMsgId(qwAddMsgTemplateResult.getMsgId());
|
|
|
+ qwGroupMsgItem.setCorpId(qwGroupMsgParam.getCorpId());
|
|
|
+ qwGroupMsgItem.setCompanyId(qwCompany.getId());
|
|
|
+ //附件做记录
|
|
|
+ int i1 = qwGroupMsgItemMapper.insertQwGroupMsgItem(qwGroupMsgItem);
|
|
|
+
|
|
|
+ if (i1 <= 0) {
|
|
|
+ logger.error("录入入群发消息附件表失败");
|
|
|
+ }else {
|
|
|
+ List<QwGroupMsgUser> qwGroupMsgUserList=new ArrayList<>();
|
|
|
+
|
|
|
+ for (String excId : customerList) {
|
|
|
+
|
|
|
+ QwGroupMsgUser ext=new QwGroupMsgUser();
|
|
|
+ ext.setUserId(quId);
|
|
|
+ ext.setStatus(0);
|
|
|
+ ext.setMsgId(qwAddMsgTemplateResult.getMsgId());
|
|
|
+ ext.setChatType(qwGroupMsgParam.getChatType());
|
|
|
+ ext.setCorpId(qwGroupMsgParam.getCorpId());
|
|
|
+ ext.setCompanyId(qwCompany.getId());
|
|
|
+ ext.setGroupMsgId(qwGroupMsg.getId());
|
|
|
+ ext.setExternalUserid(excId);
|
|
|
+ ext.setSendStatus(0);
|
|
|
+ ext.setSendTime(0L);
|
|
|
+ qwGroupMsgUserList.add(ext);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ boolean isSuccess = qwGroupMsgUserService.saveBatch(qwGroupMsgUserList,500);
|
|
|
+ if (!isSuccess) {
|
|
|
+ logger.error("批量录入群发成员发送任务及执行结果反馈记录表失败41063");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ // 插入失败的处理逻辑
|
|
|
+ logger.error("录入入群发消息主表失败");
|
|
|
}
|
|
|
- else {
|
|
|
|
|
|
- //记录一条
|
|
|
- qwGroupMsgUser.setChatType(qwGroupMsgParam.getChatType());
|
|
|
- qwGroupMsgUser.setCorpId(qwGroupMsgParam.getCorpId());
|
|
|
- qwGroupMsgUser.setCompanyId(null);
|
|
|
- qwGroupMsgUser.setGroupMsgId(qwGroupMsg.getId());
|
|
|
- qwGroupMsgUser.setMsgId(qwAddMsgTemplateResult.getMsgId());
|
|
|
- qwGroupMsgUser.setUserId(qwUserid);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ //发送这条消息文本的成员集合
|
|
|
+ qwGroupMsg.setSender(userIdsSelectList.toString());
|
|
|
+ qwGroupMsg.setAllowSelect(qwGroupMsgParam.getAllowSelect());
|
|
|
+ qwGroupMsg.setTextContent(qwGroupMsgParam.getTextContent());
|
|
|
+ qwGroupMsg.setCreateName(qwGroupMsgParam.getCreateName());
|
|
|
+ qwGroupMsg.setGroupChatNames(qwGroupMsgParam.getGroupChatNames());
|
|
|
|
|
|
- //群发成员发送任务及执行结果反馈记录
|
|
|
- qwGroupMsgUserMapper.insertQwGroupMsgUser(qwGroupMsgUser);
|
|
|
+ //如果发送给客户群
|
|
|
+ if (qwGroupMsgParam.getChatType().equals("group")){
|
|
|
|
|
|
- QwGetGroupMsgTask qwGetGroupMsgTask=new QwGetGroupMsgTask();
|
|
|
- qwGetGroupMsgTask.setMsgid(qwAddMsgTemplateResult.getMsgId());
|
|
|
- qwGetGroupMsgTask.setLimit(1000);
|
|
|
+ qwGroupMsg.setFilterCustomers(JSON.toJSONString(qwGroupMsgParam.getGroupChatNamesMap()));
|
|
|
|
|
|
- //延迟4秒
|
|
|
- Thread.sleep(4000);
|
|
|
+ //定时发送时,就只存记录
|
|
|
+ if (qwGroupMsgParam.getIsTimerSend()==1){
|
|
|
|
|
|
- //获取群发成员发送任务列表 (只有状态为2,即成员选择发送了群聊后,才能看见 有哪些群聊(群聊列表))
|
|
|
- QwGetGroupmsgTaskResult groupmsgTask = qwApiService.getGroupmsgTask(qwGetGroupMsgTask, qwGroupMsgParam.getCorpId());
|
|
|
+ qwGroupMsg.setIsSend(3);
|
|
|
+ qwGroupMsg.setIsTimerSend(1);
|
|
|
+ qwGroupMsg.setTimerSend(qwGroupMsgParam.getTimerSend());
|
|
|
+ qwGroupMsg.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
|
- if (groupmsgTask.getErrCode()==2){
|
|
|
+ //主表做记录
|
|
|
+ insertRecordsGroup(qwGroupMsg,qwGroupMsgItem,qwGroupMsgParam.getCorpId(),qwCompany.getId());
|
|
|
|
|
|
- QwGetGroupmsgSendParam qwGetGroupmsgSendParam=new QwGetGroupmsgSendParam();
|
|
|
- //获取企业群发成员执行结果(发送给客户群的话,要成员选择发送了之后,才会有列表)
|
|
|
- qwGetGroupmsgSendParam.setUserid(qwUserid);
|
|
|
- qwGetGroupmsgSendParam.setMsgid(qwAddMsgTemplateResult.getMsgId());
|
|
|
- qwGetGroupmsgSendParam.setLimit(1000);
|
|
|
+ return R.ok();
|
|
|
+ }else {
|
|
|
|
|
|
- QwGroupmsgSendResult groupmsgSendResult = qwApiService.getGroupmsgSendResult(qwGetGroupmsgSendParam, qwGroupMsgParam.getCorpId());
|
|
|
- if (groupmsgSendResult.getErrCode()!=0){
|
|
|
- return R.error("获取企业群发成员执行结果失败:"+groupmsgSendResult.getErrMsg());
|
|
|
- }else {
|
|
|
- List<SendItemResult> sendList = groupmsgSendResult.getSendList();
|
|
|
+ qwGroupMsg.setIsSend(1);
|
|
|
+ qwGroupMsg.setCreateTime(DateUtils.getNowDate());
|
|
|
+ //主表做记录
|
|
|
+ insertRecordsGroup(qwGroupMsg,qwGroupMsgItem,qwGroupMsgParam.getCorpId(),qwCompany.getId());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //因为群发群,群主只能选择一个一个发
|
|
|
+ for (String qwUserid: qwGroupMsgParam.getUserIdsSelectList()) {
|
|
|
+ HashMap<String, ArrayList<String>> groupChatNamesMap = qwGroupMsgParam.getGroupChatNamesMap();
|
|
|
+ if (groupChatNamesMap.containsKey(qwUserid)){
|
|
|
+ ArrayList<String> arrayList = groupChatNamesMap.get(qwUserid);
|
|
|
+ if (!arrayList.isEmpty()){
|
|
|
+
|
|
|
+ msgTemplate.setChatType(qwGroupMsgParam.getChatType());
|
|
|
+ msgTemplate.setSender(qwUserid);
|
|
|
+ msgTemplate.setAllowSelect(qwGroupMsgParam.getAllowSelect()==1?true:false);
|
|
|
+ msgTemplate.setTextContent(qwGroupMsgParam.getTextContent());
|
|
|
+ msgTemplate.setType(qwGroupMsgParam.getMsgType());
|
|
|
+ msgTemplate.setChatIdList(arrayList);
|
|
|
+
|
|
|
+ QwAddMsgTemplateResult qwAddMsgTemplateResult = qwApiService.addMsgTemplate(msgTemplate,qwGroupMsgParam.getCorpId());
|
|
|
+
|
|
|
+ if (qwAddMsgTemplateResult.getErrCode()!=0){
|
|
|
+ qwGroupMsg.setIsSend(0);
|
|
|
+ qwGroupMsg.setCreateTime(DateUtils.getNowDate());
|
|
|
+ //主表做记录
|
|
|
+ insertRecordsGroup(qwGroupMsg,qwGroupMsgItem,qwGroupMsgParam.getCorpId(),qwCompany.getId());
|
|
|
+ return R.error("成员:"+qwUserid+"/群群发消息失败"+":"+qwAddMsgTemplateResult.getErrMsg());
|
|
|
+ }
|
|
|
+ else {
|
|
|
+
|
|
|
+ //记录一条
|
|
|
+ qwGroupMsgUser.setChatType(qwGroupMsgParam.getChatType());
|
|
|
+ qwGroupMsgUser.setCorpId(qwGroupMsgParam.getCorpId());
|
|
|
+ qwGroupMsgUser.setCompanyId(null);
|
|
|
+ qwGroupMsgUser.setGroupMsgId(qwGroupMsg.getId());
|
|
|
+ qwGroupMsgUser.setMsgId(qwAddMsgTemplateResult.getMsgId());
|
|
|
+ qwGroupMsgUser.setUserId(qwUserid);
|
|
|
+
|
|
|
+ //群发成员发送任务及执行结果反馈记录
|
|
|
+ qwGroupMsgUserMapper.insertQwGroupMsgUser(qwGroupMsgUser);
|
|
|
+
|
|
|
+ QwGetGroupMsgTask qwGetGroupMsgTask=new QwGetGroupMsgTask();
|
|
|
+ qwGetGroupMsgTask.setMsgid(qwAddMsgTemplateResult.getMsgId());
|
|
|
+ qwGetGroupMsgTask.setLimit(1000);
|
|
|
+
|
|
|
+ //延迟4秒
|
|
|
+ Thread.sleep(4000);
|
|
|
+
|
|
|
+ //获取群发成员发送任务列表 (只有状态为2,即成员选择发送了群聊后,才能看见 有哪些群聊(群聊列表))
|
|
|
+ QwGetGroupmsgTaskResult groupmsgTask = qwApiService.getGroupmsgTask(qwGetGroupMsgTask, qwGroupMsgParam.getCorpId());
|
|
|
+
|
|
|
+ if (groupmsgTask.getErrCode()==2){
|
|
|
+
|
|
|
+ QwGetGroupmsgSendParam qwGetGroupmsgSendParam=new QwGetGroupmsgSendParam();
|
|
|
+ //获取企业群发成员执行结果(发送给客户群的话,要成员选择发送了之后,才会有列表)
|
|
|
+ qwGetGroupmsgSendParam.setUserid(qwUserid);
|
|
|
+ qwGetGroupmsgSendParam.setMsgid(qwAddMsgTemplateResult.getMsgId());
|
|
|
+ qwGetGroupmsgSendParam.setLimit(1000);
|
|
|
+
|
|
|
+ QwGroupmsgSendResult groupmsgSendResult = qwApiService.getGroupmsgSendResult(qwGetGroupmsgSendParam, qwGroupMsgParam.getCorpId());
|
|
|
+ if (groupmsgSendResult.getErrCode()!=0){
|
|
|
+ return R.error("获取企业群发成员执行结果失败:"+groupmsgSendResult.getErrMsg());
|
|
|
+ }else {
|
|
|
+ List<SendItemResult> sendList = groupmsgSendResult.getSendList();
|
|
|
+
|
|
|
+ for (SendItemResult send: sendList) {
|
|
|
+
|
|
|
+ qwGroupMsgUser.setChatType(qwGroupMsgParam.getChatType());
|
|
|
+ qwGroupMsgUser.setCorpId(qwGroupMsgParam.getCorpId());
|
|
|
+ qwGroupMsgUser.setCompanyId(qwCompany.getId());
|
|
|
+ qwGroupMsgUser.setGroupMsgId(qwGroupMsg.getId());
|
|
|
+ qwGroupMsgUser.setUserId(send.getUserId());
|
|
|
+ qwGroupMsgUser.setMsgId(qwAddMsgTemplateResult.getMsgId());
|
|
|
+ //群聊id
|
|
|
+ qwGroupMsgUser.setChatId(send.getChatId());
|
|
|
+ //发送时间
|
|
|
+ qwGroupMsgUser.setSendTime(send.getSendTime());
|
|
|
+ //发送状态
|
|
|
+ qwGroupMsgUser.setSendStatus(send.getStatus());
|
|
|
|
|
|
- for (SendItemResult send: sendList) {
|
|
|
-
|
|
|
- qwGroupMsgUser.setChatType(qwGroupMsgParam.getChatType());
|
|
|
- qwGroupMsgUser.setCorpId(qwGroupMsgParam.getCorpId());
|
|
|
- qwGroupMsgUser.setCompanyId(qwCompany.getId());
|
|
|
- qwGroupMsgUser.setGroupMsgId(qwGroupMsg.getId());
|
|
|
- qwGroupMsgUser.setUserId(send.getUserId());
|
|
|
- qwGroupMsgUser.setMsgId(qwAddMsgTemplateResult.getMsgId());
|
|
|
- //群聊id
|
|
|
- qwGroupMsgUser.setChatId(send.getChatId());
|
|
|
- //发送时间
|
|
|
- qwGroupMsgUser.setSendTime(send.getSendTime());
|
|
|
- //发送状态
|
|
|
- qwGroupMsgUser.setSendStatus(send.getStatus());
|
|
|
-
|
|
|
- //群发成员发送任务及执行结果反馈记录
|
|
|
- qwGroupMsgUserMapper.insertQwGroupMsgUser(qwGroupMsgUser);
|
|
|
+ //群发成员发送任务及执行结果反馈记录
|
|
|
+ qwGroupMsgUserMapper.insertQwGroupMsgUser(qwGroupMsgUser);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- }
|
|
|
- else if (qwGroupMsgParam.getChatType().equals("single")){
|
|
|
-
|
|
|
- qwGroupMsg.setSelectType(qwGroupMsgParam.getSelectType());
|
|
|
- //筛选出客户
|
|
|
- QwCountCustomerParam qwCountCustomerParam=new QwCountCustomerParam();
|
|
|
- qwCountCustomerParam.setUserIdsSelectList(qwGroupMsgParam.getUserIdsSelectList());
|
|
|
- qwCountCustomerParam.setSelectType(qwGroupMsgParam.getSelectType());
|
|
|
- qwCountCustomerParam.setGender(qwGroupMsgParam.getGender());
|
|
|
- qwCountCustomerParam.setGroupChatSelectList(qwGroupMsgParam.getGroupChatSelectList());
|
|
|
- qwCountCustomerParam.setTimeScreenCharge(qwGroupMsgParam.getTimeScreenCharge());
|
|
|
- qwCountCustomerParam.setTagsIdsSelectList(qwGroupMsgParam.getTagsIdsSelectList());
|
|
|
- qwCountCustomerParam.setOutTagsIdsSelectList(qwGroupMsgParam.getOutTagsIdsSelectList());
|
|
|
-
|
|
|
- //根据 条件 筛选出预计发送的客户id列表
|
|
|
- ArrayList<String> customerList= qwExternalContactService.selectQwGroupMsgExpectCustomerList(qwCountCustomerParam, qwCompany.getCorpId());
|
|
|
-
|
|
|
- qwGroupMsg.setToUserNum(customerList.size());
|
|
|
- qwGroupMsg.setFilterCustomers(JSON.toJSONString(qwCountCustomerParam));
|
|
|
-
|
|
|
- //客户列表
|
|
|
- msgTemplate.setExternalUseridList(customerList);
|
|
|
-
|
|
|
- //发送消息文本组装
|
|
|
- //群发任务类型()
|
|
|
- msgTemplate.setChatType(qwGroupMsgParam.getChatType());
|
|
|
-
|
|
|
- msgTemplate.setAllowSelect(qwGroupMsgParam.getAllowSelect()==1?true:false);
|
|
|
- msgTemplate.setTextContent(qwGroupMsgParam.getTextContent());
|
|
|
- msgTemplate.setType(qwGroupMsgParam.getMsgType());
|
|
|
-
|
|
|
- //开启定时发送时 就制作记录
|
|
|
- if (qwGroupMsgParam.getIsTimerSend()==1){
|
|
|
- //发送失败 主表做记录
|
|
|
- qwGroupMsg.setIsSend(3);
|
|
|
- qwGroupMsg.setIsTimerSend(1);
|
|
|
- qwGroupMsg.setTimerSend(qwGroupMsgParam.getTimerSend());
|
|
|
- qwGroupMsg.setCreateTime(DateUtils.getNowDate());
|
|
|
-
|
|
|
- //主表做记录
|
|
|
- insertRecordsGroup(qwGroupMsg,qwGroupMsgItem,qwGroupMsgParam.getCorpId(),qwCompany.getId());
|
|
|
- return R.ok();
|
|
|
}
|
|
|
+ else if (qwGroupMsgParam.getChatType().equals("single")){
|
|
|
+
|
|
|
+ qwGroupMsg.setSelectType(qwGroupMsgParam.getSelectType());
|
|
|
+ //筛选出客户
|
|
|
+ QwCountCustomerParam qwCountCustomerParam=new QwCountCustomerParam();
|
|
|
+ qwCountCustomerParam.setUserIdsSelectList(qwGroupMsgParam.getUserIdsSelectList());
|
|
|
+ qwCountCustomerParam.setSelectType(qwGroupMsgParam.getSelectType());
|
|
|
+ qwCountCustomerParam.setGender(qwGroupMsgParam.getGender());
|
|
|
+ qwCountCustomerParam.setGroupChatSelectList(qwGroupMsgParam.getGroupChatSelectList());
|
|
|
+ qwCountCustomerParam.setTimeScreenCharge(qwGroupMsgParam.getTimeScreenCharge());
|
|
|
+ qwCountCustomerParam.setTagsIdsSelectList(qwGroupMsgParam.getTagsIdsSelectList());
|
|
|
+ qwCountCustomerParam.setOutTagsIdsSelectList(qwGroupMsgParam.getOutTagsIdsSelectList());
|
|
|
|
|
|
+ //根据 条件 筛选出预计发送的客户id列表
|
|
|
+ ArrayList<String> customerList= qwExternalContactService.selectQwGroupMsgExpectCustomerList(qwCountCustomerParam, qwCompany.getCorpId());
|
|
|
|
|
|
- QwAddMsgTemplateResult qwAddMsgTemplateResult = qwApiService.addMsgTemplate(msgTemplate, qwGroupMsgParam.getCorpId());
|
|
|
+ qwGroupMsg.setToUserNum(customerList.size());
|
|
|
+ qwGroupMsg.setFilterCustomers(JSON.toJSONString(qwCountCustomerParam));
|
|
|
|
|
|
- qwGroupMsg.setMsgid(qwAddMsgTemplateResult.getMsgId() == null ? null : qwAddMsgTemplateResult.getMsgId());
|
|
|
+ //客户列表
|
|
|
+ msgTemplate.setExternalUseridList(customerList);
|
|
|
|
|
|
- //延迟三秒
|
|
|
- Thread.sleep(4000);
|
|
|
+ //发送消息文本组装
|
|
|
+ //群发任务类型()
|
|
|
+ msgTemplate.setChatType(qwGroupMsgParam.getChatType());
|
|
|
|
|
|
- if (qwAddMsgTemplateResult.getErrCode()!=0){
|
|
|
+ msgTemplate.setAllowSelect(qwGroupMsgParam.getAllowSelect()==1?true:false);
|
|
|
+ msgTemplate.setTextContent(qwGroupMsgParam.getTextContent());
|
|
|
+ msgTemplate.setType(qwGroupMsgParam.getMsgType());
|
|
|
|
|
|
- //发送失败 主表做记录
|
|
|
- qwGroupMsg.setIsSend(0);
|
|
|
- qwGroupMsg.setCreateTime(DateUtils.getNowDate());
|
|
|
- //主表做记录
|
|
|
- insertQwGroupMsgSinger(qwGroupMsg,qwGroupMsgItem,qwGroupMsgParam.getCorpId(),qwCompany.getId(),qwAddMsgTemplateResult);
|
|
|
+ //开启定时发送时 就制作记录
|
|
|
+ if (qwGroupMsgParam.getIsTimerSend()==1){
|
|
|
+ //发送失败 主表做记录
|
|
|
+ qwGroupMsg.setIsSend(3);
|
|
|
+ qwGroupMsg.setIsTimerSend(1);
|
|
|
+ qwGroupMsg.setTimerSend(qwGroupMsgParam.getTimerSend());
|
|
|
+ qwGroupMsg.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
|
- return R.error("消息发送失败:"+qwAddMsgTemplateResult.getErrMsg());
|
|
|
- }
|
|
|
- else if (qwAddMsgTemplateResult.getErrCode()==41063){
|
|
|
+ //主表做记录
|
|
|
+ insertRecordsGroup(qwGroupMsg,qwGroupMsgItem,qwGroupMsgParam.getCorpId(),qwCompany.getId());
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
|
|
|
- qwGroupMsg.setIsSend(2);
|
|
|
- qwGroupMsg.setCreateTime(DateUtils.getNowDate());
|
|
|
- //主表做记录
|
|
|
- insertQwGroupMsgSinger(qwGroupMsg,qwGroupMsgItem,qwGroupMsgParam.getCorpId(),qwCompany.getId(),qwAddMsgTemplateResult);
|
|
|
- return R.ok("消息发送成功-待更新");
|
|
|
- }
|
|
|
- else {
|
|
|
|
|
|
- QwGetGroupMsgTask qwGetGroupMsgTask=new QwGetGroupMsgTask();
|
|
|
- qwGetGroupMsgTask.setMsgid(qwAddMsgTemplateResult.getMsgId());
|
|
|
- qwGetGroupMsgTask.setLimit(1000);
|
|
|
+ QwAddMsgTemplateResult qwAddMsgTemplateResult = qwApiService.addMsgTemplate(msgTemplate, qwGroupMsgParam.getCorpId());
|
|
|
|
|
|
- //获取群发成员发送任务列表
|
|
|
- QwGetGroupmsgTaskResult groupmsgTask = qwApiService.getGroupmsgTask(qwGetGroupMsgTask, qwGroupMsgParam.getCorpId());
|
|
|
+ qwGroupMsg.setMsgid(qwAddMsgTemplateResult.getMsgId() == null ? null : qwAddMsgTemplateResult.getMsgId());
|
|
|
|
|
|
- if (groupmsgTask.getErrCode()!=0){
|
|
|
+ //延迟三秒
|
|
|
+ Thread.sleep(4000);
|
|
|
|
|
|
- if (groupmsgTask.getErrCode()==41063){
|
|
|
- //正在发送 主表做记录
|
|
|
- qwGroupMsg.setIsSend(2);
|
|
|
- qwGroupMsg.setIsTimerSend(2);
|
|
|
- qwGroupMsg.setCreateTime(DateUtils.getNowDate());
|
|
|
+ if (qwAddMsgTemplateResult.getErrCode()!=0){
|
|
|
|
|
|
- //主表做记录
|
|
|
- insertRecordsGroup(qwGroupMsg,qwGroupMsgItem,qwGroupMsgParam.getCorpId(),qwCompany.getId());
|
|
|
- return R.ok("消息发送成功-待更新");
|
|
|
- }else {
|
|
|
- //失败了 主表做记录
|
|
|
+ //发送失败 主表做记录
|
|
|
qwGroupMsg.setIsSend(0);
|
|
|
- qwGroupMsg.setIsTimerSend(2);
|
|
|
qwGroupMsg.setCreateTime(DateUtils.getNowDate());
|
|
|
+ //主表做记录
|
|
|
+ insertQwGroupMsgSinger(qwGroupMsg,qwGroupMsgItem,qwGroupMsgParam.getCorpId(),qwCompany.getId(),qwAddMsgTemplateResult);
|
|
|
|
|
|
+ return R.error("消息发送失败:"+qwAddMsgTemplateResult.getErrMsg());
|
|
|
+ }
|
|
|
+ else if (qwAddMsgTemplateResult.getErrCode()==41063){
|
|
|
+
|
|
|
+ qwGroupMsg.setIsSend(2);
|
|
|
+ qwGroupMsg.setCreateTime(DateUtils.getNowDate());
|
|
|
//主表做记录
|
|
|
- insertRecordsGroup(qwGroupMsg,qwGroupMsgItem,qwGroupMsgParam.getCorpId(),qwCompany.getId());
|
|
|
- return R.error("获取群发成员发送任务列表失败:"+qwAddMsgTemplateResult.getErrMsg());
|
|
|
+ insertQwGroupMsgSinger(qwGroupMsg,qwGroupMsgItem,qwGroupMsgParam.getCorpId(),qwCompany.getId(),qwAddMsgTemplateResult);
|
|
|
+ return R.ok("消息发送成功-待更新");
|
|
|
}
|
|
|
+ else {
|
|
|
|
|
|
- }
|
|
|
- else{
|
|
|
- List<TaskItemResult> taskList = groupmsgTask.getTaskList();
|
|
|
- //发送成员总数
|
|
|
- int size = taskList.size();
|
|
|
-
|
|
|
- qwGroupMsg.setFromUserNum(size);
|
|
|
- qwGroupMsg.setIsSend(1);
|
|
|
- qwGroupMsg.setCreateTime(DateUtils.getNowDate());
|
|
|
-
|
|
|
- //主表做记录
|
|
|
- int i = qwGroupMsgMapper.insertQwGroupMsg(qwGroupMsg);
|
|
|
- if (i>0){
|
|
|
-
|
|
|
- qwGroupMsgItem.setGroupMsgId(qwGroupMsg.getId());
|
|
|
- qwGroupMsgItem.setMsgId(qwAddMsgTemplateResult.getMsgId());
|
|
|
- qwGroupMsgItem.setCorpId(qwGroupMsgParam.getCorpId());
|
|
|
- qwGroupMsgItem.setCompanyId(qwCompany.getId());
|
|
|
- //附件做记录
|
|
|
- int i1 = qwGroupMsgItemMapper.insertQwGroupMsgItem(qwGroupMsgItem);
|
|
|
-
|
|
|
- if (i1<=0){
|
|
|
- return R.error("录入入群发消息附件表失败");
|
|
|
- }
|
|
|
+ QwGetGroupMsgTask qwGetGroupMsgTask=new QwGetGroupMsgTask();
|
|
|
+ qwGetGroupMsgTask.setMsgid(qwAddMsgTemplateResult.getMsgId());
|
|
|
+ qwGetGroupMsgTask.setLimit(1000);
|
|
|
|
|
|
- QwGetGroupmsgSendParam qwGetGroupmsgSendParam=new QwGetGroupmsgSendParam();
|
|
|
+ //获取群发成员发送任务列表
|
|
|
+ QwGetGroupmsgTaskResult groupmsgTask = qwApiService.getGroupmsgTask(qwGetGroupMsgTask, qwGroupMsgParam.getCorpId());
|
|
|
|
|
|
- //根据群发成员发送任务列表获取到 循环获取到各个成员的执行结果(含客户列表)
|
|
|
- for (TaskItemResult list:taskList){
|
|
|
- String userId = list.getUserId();
|
|
|
+ if (groupmsgTask.getErrCode()!=0){
|
|
|
|
|
|
- //获取企业群发成员执行结果
|
|
|
- qwGetGroupmsgSendParam.setUserid(userId);
|
|
|
- qwGetGroupmsgSendParam.setMsgid(qwAddMsgTemplateResult.getMsgId());
|
|
|
- qwGetGroupmsgSendParam.setLimit(1000);
|
|
|
- QwGroupmsgSendResult groupmsgSendResult = qwApiService.getGroupmsgSendResult(qwGetGroupmsgSendParam, qwGroupMsgParam.getCorpId());
|
|
|
+ if (groupmsgTask.getErrCode()==41063){
|
|
|
+ //正在发送 主表做记录
|
|
|
+ qwGroupMsg.setIsSend(2);
|
|
|
+ qwGroupMsg.setIsTimerSend(2);
|
|
|
+ qwGroupMsg.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
|
- if (groupmsgSendResult.getErrCode()!=0){
|
|
|
- return R.error("获取成员执行结果失败");
|
|
|
+ //主表做记录
|
|
|
+ insertRecordsGroup(qwGroupMsg,qwGroupMsgItem,qwGroupMsgParam.getCorpId(),qwCompany.getId());
|
|
|
+ return R.ok("消息发送成功-待更新");
|
|
|
}else {
|
|
|
- List<SendItemResult> sendList = groupmsgSendResult.getSendList();
|
|
|
- for (SendItemResult itemResult: sendList ) {
|
|
|
+ //失败了 主表做记录
|
|
|
+ qwGroupMsg.setIsSend(0);
|
|
|
+ qwGroupMsg.setIsTimerSend(2);
|
|
|
+ qwGroupMsg.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
|
- qwGroupMsgUser.setUserId(userId);
|
|
|
- qwGroupMsgUser.setStatus(list.getStatus());
|
|
|
- qwGroupMsgUser.setMsgId(qwAddMsgTemplateResult.getMsgId());
|
|
|
- qwGroupMsgUser.setChatType(qwGroupMsgParam.getChatType());
|
|
|
- qwGroupMsgUser.setCorpId(qwGroupMsgParam.getCorpId());
|
|
|
- qwGroupMsgUser.setCompanyId(qwCompany.getId());
|
|
|
- qwGroupMsgUser.setGroupMsgId(qwGroupMsg.getId());
|
|
|
- qwGroupMsgUser.setExternalUserid(itemResult.getExternalUserId());
|
|
|
- qwGroupMsgUser.setSendStatus(itemResult.getStatus());
|
|
|
- qwGroupMsgUser.setSendTime(itemResult.getSendTime());
|
|
|
+ //主表做记录
|
|
|
+ insertRecordsGroup(qwGroupMsg,qwGroupMsgItem,qwGroupMsgParam.getCorpId(),qwCompany.getId());
|
|
|
+ return R.error("获取群发成员发送任务列表失败:"+qwAddMsgTemplateResult.getErrMsg());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ List<TaskItemResult> taskList = groupmsgTask.getTaskList();
|
|
|
+ //发送成员总数
|
|
|
+ int size = taskList.size();
|
|
|
+
|
|
|
+ qwGroupMsg.setFromUserNum(size);
|
|
|
+ qwGroupMsg.setIsSend(1);
|
|
|
+ qwGroupMsg.setCreateTime(DateUtils.getNowDate());
|
|
|
+
|
|
|
+ //主表做记录
|
|
|
+ int i = qwGroupMsgMapper.insertQwGroupMsg(qwGroupMsg);
|
|
|
+ if (i>0){
|
|
|
+
|
|
|
+ qwGroupMsgItem.setGroupMsgId(qwGroupMsg.getId());
|
|
|
+ qwGroupMsgItem.setMsgId(qwAddMsgTemplateResult.getMsgId());
|
|
|
+ qwGroupMsgItem.setCorpId(qwGroupMsgParam.getCorpId());
|
|
|
+ qwGroupMsgItem.setCompanyId(qwCompany.getId());
|
|
|
+ //附件做记录
|
|
|
+ int i1 = qwGroupMsgItemMapper.insertQwGroupMsgItem(qwGroupMsgItem);
|
|
|
+
|
|
|
+ if (i1<=0){
|
|
|
+ return R.error("录入入群发消息附件表失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ QwGetGroupmsgSendParam qwGetGroupmsgSendParam=new QwGetGroupmsgSendParam();
|
|
|
+
|
|
|
+ //根据群发成员发送任务列表获取到 循环获取到各个成员的执行结果(含客户列表)
|
|
|
+ for (TaskItemResult list:taskList){
|
|
|
+ String userId = list.getUserId();
|
|
|
+
|
|
|
+ //获取企业群发成员执行结果
|
|
|
+ qwGetGroupmsgSendParam.setUserid(userId);
|
|
|
+ qwGetGroupmsgSendParam.setMsgid(qwAddMsgTemplateResult.getMsgId());
|
|
|
+ qwGetGroupmsgSendParam.setLimit(1000);
|
|
|
+ QwGroupmsgSendResult groupmsgSendResult = qwApiService.getGroupmsgSendResult(qwGetGroupmsgSendParam, qwGroupMsgParam.getCorpId());
|
|
|
+
|
|
|
+ if (groupmsgSendResult.getErrCode()!=0){
|
|
|
+ return R.error("获取成员执行结果失败");
|
|
|
+ }else {
|
|
|
+ List<SendItemResult> sendList = groupmsgSendResult.getSendList();
|
|
|
+
|
|
|
+ List<QwGroupMsgUser> qwGroupMsgUserList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (SendItemResult itemResult: sendList ) {
|
|
|
+
|
|
|
+ QwGroupMsgUser ext=new QwGroupMsgUser();
|
|
|
+
|
|
|
+ ext.setUserId(userId);
|
|
|
+ ext.setStatus(list.getStatus());
|
|
|
+ ext.setMsgId(qwAddMsgTemplateResult.getMsgId());
|
|
|
+ ext.setChatType(qwGroupMsgParam.getChatType());
|
|
|
+ ext.setCorpId(qwGroupMsgParam.getCorpId());
|
|
|
+ ext.setCompanyId(qwCompany.getId());
|
|
|
+ ext.setGroupMsgId(qwGroupMsg.getId());
|
|
|
+ ext.setExternalUserid(itemResult.getExternalUserId());
|
|
|
+ ext.setSendStatus(itemResult.getStatus());
|
|
|
+ ext.setSendTime(itemResult.getSendTime());
|
|
|
+
|
|
|
+ qwGroupMsgUserList.add(ext);
|
|
|
|
|
|
- int i2 = qwGroupMsgUserMapper.insertQwGroupMsgUser(qwGroupMsgUser);
|
|
|
- if (i2<=0) {
|
|
|
- return R.error("录入群发成员发送任务及执行结果反馈记录表失败");
|
|
|
+// int i2 = qwGroupMsgUserMapper.insertQwGroupMsgUser(qwGroupMsgUser);
|
|
|
+// if (i2<=0) {
|
|
|
+// return R.error("录入群发成员发送任务及执行结果反馈记录表失败");
|
|
|
+// }
|
|
|
+ }
|
|
|
+
|
|
|
+ boolean isSuccess = qwGroupMsgUserService.saveBatch(qwGroupMsgUserList,500);
|
|
|
+ if (!isSuccess) {
|
|
|
+ logger.error("批量录入群发成员发送任务及执行结果反馈记录表失败41063");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ // 插入失败的处理逻辑
|
|
|
+ return R.error("录入入群发消息主表失败");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
- else {
|
|
|
- // 插入失败的处理逻辑
|
|
|
- return R.error("录入入群发消息主表失败");
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
|
|
|
return R.ok();
|
|
|
}
|
|
|
+ //生成小程序链接 通用链接
|
|
|
+ private String createLinkByMiniApp(Date sendTime, Long courseId, Long videoId,
|
|
|
+ QwUser qwUser, Long externalId, Integer isRoom){
|
|
|
+ FsCourseLink link = new FsCourseLink();
|
|
|
+ link.setCompanyId(qwUser.getCompanyId());
|
|
|
+ link.setQwUserId(qwUser.getId());
|
|
|
+ link.setCompanyUserId(qwUser.getCompanyUserId());
|
|
|
+ link.setVideoId(videoId);
|
|
|
+ link.setCorpId(qwUser.getCorpId());
|
|
|
+ link.setCourseId(courseId);
|
|
|
+ link.setQwExternalId(externalId);
|
|
|
+ link.setIsRoom(isRoom);
|
|
|
+ link.setLinkType(3);
|
|
|
+
|
|
|
+
|
|
|
+ String randomString = generateRandomStringWithLock();
|
|
|
+ if (StringUtil.strIsNullOrEmpty(randomString)){
|
|
|
+ link.setLink(UUID.randomUUID().toString().replace("-", ""));
|
|
|
+ }else {
|
|
|
+ link.setLink(randomString);
|
|
|
+ }
|
|
|
+
|
|
|
+ link.setCreateTime(sendTime);
|
|
|
+
|
|
|
+ FsCourseRealLink courseMap = new FsCourseRealLink();
|
|
|
+ BeanUtils.copyProperties(link,courseMap);
|
|
|
+
|
|
|
+ String courseJson = JSON.toJSONString(courseMap);
|
|
|
+
|
|
|
+ String realLinkFull = miniappRealLink + courseJson;
|
|
|
+
|
|
|
+
|
|
|
+ link.setRealLink(realLinkFull);
|
|
|
+
|
|
|
+
|
|
|
+ // 使用 Java 8 时间 API 计算过期时间
|
|
|
+ LocalDateTime sendDateTime = sendTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
|
+ LocalDateTime expireDateTime = sendDateTime.plusDays(0);
|
|
|
+ expireDateTime = expireDateTime.toLocalDate().atTime(23, 59, 59);
|
|
|
+ Date updateTime = Date.from(expireDateTime.atZone(ZoneId.systemDefault()).toInstant());
|
|
|
+ link.setUpdateTime(updateTime);
|
|
|
+
|
|
|
+ //存短链-
|
|
|
+ fsCourseLinkMapper.insertFsCourseLink(link);
|
|
|
+
|
|
|
+ return link.getRealLink();
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
/** 统计数据详情,已发送,未发送,已接收,未接收等 */
|
|
|
@Override
|