Commit f4f8d325 by zhangzhendong

修改开关

parent 32f14a6f
...@@ -18,6 +18,7 @@ import com.gic.haoban.manage.service.service.StaffClerkRelationService; ...@@ -18,6 +18,7 @@ import com.gic.haoban.manage.service.service.StaffClerkRelationService;
import com.gic.haoban.manage.service.service.WxEnterpriseService; import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.haoban.manage.service.service.message.NoticeMessageHandler; import com.gic.haoban.manage.service.service.message.NoticeMessageHandler;
import com.gic.haoban.manage.service.service.notify.NoticeMessageService; import com.gic.haoban.manage.service.service.notify.NoticeMessageService;
import com.gic.haoban.manage.service.util.ApolloUtils;
import com.gic.message.center.api.subscribe.model.NoticeMessageForm; import com.gic.message.center.api.subscribe.model.NoticeMessageForm;
import com.gic.wechat.api.dto.qywx.ItemDTO; import com.gic.wechat.api.dto.qywx.ItemDTO;
import com.gic.wechat.api.dto.qywx.QywxXcxSendMessageDTO; import com.gic.wechat.api.dto.qywx.QywxXcxSendMessageDTO;
...@@ -195,23 +196,29 @@ public class PotentialCustomerNotifyBuilder { ...@@ -195,23 +196,29 @@ public class PotentialCustomerNotifyBuilder {
log.info("企业信息不存在 {}", staffClerkRelation.getWxEnterpriseId()); log.info("企业信息不存在 {}", staffClerkRelation.getWxEnterpriseId());
continue; continue;
} }
/* 消息中心修改此处
QywxXcxSendMessageDTO messageDTO = this.buildApplicationMessage(staffClerkRelation, wxEnterpriseQwDTO, if (!ApolloUtils.useMessageCenter()){
log.info("消息中心-走老版消息通知");
/* 消息中心修改此处*/
QywxXcxSendMessageDTO messageDTO = this.buildApplicationMessage(staffClerkRelation, wxEnterpriseQwDTO,
customerStaticsBOMap.get(staffClerkRelation.getClerkId()).getNum(), context.buildExtendParams(staffClerkRelation.getStoreId(), staffClerkRelation.getClerkId())); customerStaticsBOMap.get(staffClerkRelation.getClerkId()).getNum(), context.buildExtendParams(staffClerkRelation.getStoreId(), staffClerkRelation.getClerkId()));
boolean sendMessage = qywxSuiteApiService.sendMessage(wxEnterpriseQwDTO.getThirdCorpid(), wxEnterpriseQwDTO.getSelf3thSecret(), messageDTO,wxEnterpriseQwDTO.isSelf(),wxEnterpriseQwDTO.getUrlHost()); boolean sendMessage = qywxSuiteApiService.sendMessage(wxEnterpriseQwDTO.getThirdCorpid(), wxEnterpriseQwDTO.getSelf3thSecret(), messageDTO,wxEnterpriseQwDTO.isSelf(),wxEnterpriseQwDTO.getUrlHost());
log.info("发送销售线索应用消息结果 {}", sendMessage);*/ log.info("发送销售线索应用消息结果 {}", sendMessage);
Map<String, String> variableMap = new HashMap<>(); } else {
variableMap.put("memberNum", customerStaticsBOMap.get(staffClerkRelation.getClerkId()).getNum().toString()); Map<String, String> variableMap = new HashMap<>();
variableMap.put("page", NoticeMessageUtil.buildMiniAppUrl(NoticeMessageTypeEnum.POTENTIAL_CUSTOMER_NOTIFY, context.buildExtendParams(staffClerkRelation.getStoreId(), staffClerkRelation.getClerkId()))); variableMap.put("memberNum", customerStaticsBOMap.get(staffClerkRelation.getClerkId()).getNum().toString());
noticeMessageHandler.sendMessage(NoticeMessageForm.builder() variableMap.put("page", NoticeMessageUtil.buildMiniAppUrl(NoticeMessageTypeEnum.POTENTIAL_CUSTOMER_NOTIFY, context.buildExtendParams(staffClerkRelation.getStoreId(), staffClerkRelation.getClerkId())));
.messageCode(NoticeMessageTypeEnum.POTENTIAL_CUSTOMER_NOTIFY.getMessageCode()) noticeMessageHandler.sendMessage(NoticeMessageForm.builder()
.mqRouterCode(NoticeMessageTypeEnum.POTENTIAL_CUSTOMER_NOTIFY.getRouterCode()) .messageCode(NoticeMessageTypeEnum.POTENTIAL_CUSTOMER_NOTIFY.getMessageCode())
.businessId("-1") .mqRouterCode(NoticeMessageTypeEnum.POTENTIAL_CUSTOMER_NOTIFY.getRouterCode())
.createTime(new Date()) .businessId("-1")
.enterpriseId(context.getEnterpriseId()) .createTime(new Date())
.uniqueKey(UniqueIdUtils.uniqueLongHex()) .enterpriseId(context.getEnterpriseId())
.userIdList(Collections.singletonList(staffClerkRelation.getClerkId())) .uniqueKey(UniqueIdUtils.uniqueLongHex())
.variableMap(variableMap).build()); .userIdList(Collections.singletonList(staffClerkRelation.getClerkId()))
.variableMap(variableMap).build());
}
} }
} }
......
...@@ -105,15 +105,21 @@ public class MaterialReportServiceImpl implements MaterialReportService { ...@@ -105,15 +105,21 @@ public class MaterialReportServiceImpl implements MaterialReportService {
materialReportBuilder.buildMaterialReportData(context); materialReportBuilder.buildMaterialReportData(context);
// 保存小程序消息 // 保存小程序消息
List<NoticeMessageBO> noticeMessageBos = context.buildNotifyMessageBos(); List<NoticeMessageBO> noticeMessageBos = context.buildNotifyMessageBos();
/*消息中心修改此处
if (CollectionUtils.isNotEmpty(noticeMessageBos)) {
noticeMessageService.addNoticeMessageBatch(noticeMessageBos);
}*/
}
if (StringUtils.isBlank(context.getClerkId())) { if (StringUtils.isBlank(context.getClerkId())) {
log.info("成员{}在企业{}中不存在主门店, 不推送企微应用消息", staffId, enterpriseId); log.info("成员{}在企业{}中不存在主门店, 不推送企微应用消息", staffId, enterpriseId);
return; return;
} }
if (!ApolloUtils.useMessageCenter()){
log.info("消息中心-走老版消息通知");
/*消息中心修改此处*/
if (CollectionUtils.isNotEmpty(noticeMessageBos)) {
noticeMessageService.addNoticeMessageBatch(noticeMessageBos);
}
}
// 发送企微消息 // 发送企微消息
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(staffInfo.getWxEnterpriseId()); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(staffInfo.getWxEnterpriseId());
QywxNewsSendMessageDTO newsSendMessageDTO = materialReportBuilder.buildQywxNewsMessage(context, qwDTO); QywxNewsSendMessageDTO newsSendMessageDTO = materialReportBuilder.buildQywxNewsMessage(context, qwDTO);
...@@ -123,45 +129,45 @@ public class MaterialReportServiceImpl implements MaterialReportService { ...@@ -123,45 +129,45 @@ public class MaterialReportServiceImpl implements MaterialReportService {
} }
log.info("发送企业图文消息参数{}", JSON.toJSONString(newsSendMessageDTO)); log.info("发送企业图文消息参数{}", JSON.toJSONString(newsSendMessageDTO));
/*消息中心修改此处*/ if (!ApolloUtils.useMessageCenter()){
if (!ApolloUtils.useMessageCenter()){ log.info("消息中心-走老版消息通知");
log.info("消息中心-走老版消息通知"); /*消息中心修改此处*/
/*消息中心修改此处*/ boolean result = qywxSuiteApiService.sendMessage(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), newsSendMessageDTO,qwDTO.isSelf(),qwDTO.getUrlHost());
if (CollectionUtils.isNotEmpty(noticeMessageBos)) { log.info("成员{}发送素材企微使用报告结果 {}", staffId, result);
noticeMessageService.addNoticeMessageBatch(noticeMessageBos);
}
}
boolean result = qywxSuiteApiService.sendMessage(qwDTO.getThirdCorpid(), config.getWxSuiteid(), newsSendMessageDTO);
log.info("成员{}发送素材企微使用报告结果 {}", staffId, result);
Map<String, String> variableMap = new HashMap<>();
QywxNewsArticleMessageDTO qywxNewsArticleMessageDTO = newsSendMessageDTO.getArticleMessages().get(0);
variableMap.put("image", qywxNewsArticleMessageDTO.getPicurl());
variableMap.put("page", qywxNewsArticleMessageDTO.getPagepath());
variableMap.put("templateTitle", qywxNewsArticleMessageDTO.getTitle());
variableMap.put("templateDescription", qywxNewsArticleMessageDTO.getDescription());
variableMap.put("haobanNoticeMessageList", JSONObject.toJSONString(noticeMessageBos));
NoticeMessageTypeEnum noticeMessageTypeEnum = null;
if (MaterialReportType.WEEK.getCode().equals(context.getReportType())) {
noticeMessageTypeEnum = NoticeMessageTypeEnum.MATERIAL_REPORT_NOTIFY_WEEK;
} else if (MaterialReportType.MONTH.getCode().equals(context.getReportType())) {
noticeMessageTypeEnum = NoticeMessageTypeEnum.MATERIAL_REPORT_NOTIFY_MONTH;
}
if (ObjectUtil.isNull(noticeMessageTypeEnum)){
log.info("枚举不存在 context:{}", JSONObject.toJSONString(context));
return; return;
} else {
Map<String, String> variableMap = new HashMap<>();
QywxNewsArticleMessageDTO qywxNewsArticleMessageDTO = newsSendMessageDTO.getArticleMessages().get(0);
variableMap.put("image", qywxNewsArticleMessageDTO.getPicurl());
variableMap.put("page", qywxNewsArticleMessageDTO.getPagepath());
variableMap.put("templateTitle", qywxNewsArticleMessageDTO.getTitle());
variableMap.put("templateDescription", qywxNewsArticleMessageDTO.getDescription());
variableMap.put("haobanNoticeMessageList", JSONObject.toJSONString(noticeMessageBos));
NoticeMessageTypeEnum noticeMessageTypeEnum = null;
if (MaterialReportType.WEEK.getCode().equals(context.getReportType())) {
noticeMessageTypeEnum = NoticeMessageTypeEnum.MATERIAL_REPORT_NOTIFY_WEEK;
} else if (MaterialReportType.MONTH.getCode().equals(context.getReportType())) {
noticeMessageTypeEnum = NoticeMessageTypeEnum.MATERIAL_REPORT_NOTIFY_MONTH;
}
if (ObjectUtil.isNull(noticeMessageTypeEnum)){
log.info("枚举不存在 context:{}", JSONObject.toJSONString(context));
return;
}
noticeMessageHandler.sendMessage(NoticeMessageForm.builder()
.messageCode(noticeMessageTypeEnum.getMessageCode())
.mqRouterCode(noticeMessageTypeEnum.getRouterCode())
.businessId("-1")
.createTime(new Date())
.enterpriseId(context.getEnterpriseId())
.uniqueKey(UniqueIdUtils.uniqueLongHex())
.userIdList(context.getClerkId() == null ? new ArrayList<>() : Collections.singletonList(context.getClerkId()))
.variableMap(variableMap).build());
} }
noticeMessageHandler.sendMessage(NoticeMessageForm.builder()
.messageCode(noticeMessageTypeEnum.getMessageCode())
.mqRouterCode(noticeMessageTypeEnum.getRouterCode())
.businessId("-1") /*boolean result = qywxSuiteApiService.sendMessage(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), newsSendMessageDTO,qwDTO.isSelf(),qwDTO.getUrlHost());
.createTime(new Date()) log.info("成员{}发送素材企微使用报告结果 {}", staffId, result);*/
.enterpriseId(context.getEnterpriseId())
.uniqueKey(UniqueIdUtils.uniqueLongHex())
.userIdList(context.getClerkId() == null ? new ArrayList<>() : Collections.singletonList(context.getClerkId()))
.variableMap(variableMap).build());
boolean result = qywxSuiteApiService.sendMessage(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), newsSendMessageDTO,qwDTO.isSelf(),qwDTO.getUrlHost());
log.info("成员{}发送素材企微使用报告结果 {}", staffId, result);
} }
} }
...@@ -21,6 +21,7 @@ import com.gic.haoban.manage.service.service.content.InteractRecordService; ...@@ -21,6 +21,7 @@ import com.gic.haoban.manage.service.service.content.InteractRecordService;
import com.gic.haoban.manage.service.service.content.PotentialCustomerService; import com.gic.haoban.manage.service.service.content.PotentialCustomerService;
import com.gic.haoban.manage.service.service.content.adaptor.InteractRecordMessageBuilder; import com.gic.haoban.manage.service.service.content.adaptor.InteractRecordMessageBuilder;
import com.gic.haoban.manage.service.service.content.adaptor.PotentialCustomerNotifyBuilder; import com.gic.haoban.manage.service.service.content.adaptor.PotentialCustomerNotifyBuilder;
import com.gic.haoban.manage.service.util.ApolloUtils;
import com.gic.member.api.dto.es.MemberDataDTO; import com.gic.member.api.dto.es.MemberDataDTO;
import com.gic.member.api.service.MemberOutApiService; import com.gic.member.api.service.MemberOutApiService;
import com.gic.search.engine.api.constant.MemberDataEnum; import com.gic.search.engine.api.constant.MemberDataEnum;
...@@ -263,8 +264,13 @@ public class PotentialCustomerServiceImpl implements PotentialCustomerService { ...@@ -263,8 +264,13 @@ public class PotentialCustomerServiceImpl implements PotentialCustomerService {
// 区经 忽略 // 区经 忽略
potentialCustomerNotifyBuilder.filterAreaManage(context); potentialCustomerNotifyBuilder.filterAreaManage(context);
// 构建应用内消息 // 构建应用内消息
/*消息中心修改此处 /*消息中心修改此处*/
potentialCustomerNotifyBuilder.sendHaoBanNotifyMessage(context);*/ if (!ApolloUtils.useMessageCenter()){
log.info("消息中心-走老版消息通知");
/*消息中心修改此处*/
potentialCustomerNotifyBuilder.sendHaoBanNotifyMessage(context);
}
// 如果该导购id是成员在主门店时的导购id 发送应用消息 // 如果该导购id是成员在主门店时的导购id 发送应用消息
// 如果本批数据中无成员主门店数据 则不发送 // 如果本批数据中无成员主门店数据 则不发送
potentialCustomerNotifyBuilder.sendApplicationMessage(context); potentialCustomerNotifyBuilder.sendApplicationMessage(context);
......
...@@ -26,6 +26,7 @@ import com.gic.haoban.manage.api.util.notify.NoticeMessageUtil; ...@@ -26,6 +26,7 @@ import com.gic.haoban.manage.api.util.notify.NoticeMessageUtil;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise; import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise;
import com.gic.haoban.manage.service.service.WxEnterpriseRelatedService; import com.gic.haoban.manage.service.service.WxEnterpriseRelatedService;
import com.gic.haoban.manage.service.service.message.NoticeMessageHandler; import com.gic.haoban.manage.service.service.message.NoticeMessageHandler;
import com.gic.haoban.manage.service.util.ApolloUtils;
import com.gic.message.center.api.subscribe.model.NoticeMessageForm; import com.gic.message.center.api.subscribe.model.NoticeMessageForm;
import com.gic.wechat.api.dto.qywx.QywxTemplateCardSendMessageDTO; import com.gic.wechat.api.dto.qywx.QywxTemplateCardSendMessageDTO;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
...@@ -102,8 +103,8 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService { ...@@ -102,8 +103,8 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
private NoticeMessageHandler noticeMessageHandler; private NoticeMessageHandler noticeMessageHandler;
/*消息中心修改此处 /*消息中心修改此处
@Override @Override*/
public void noticeMessageMq(String json) { public void noticeMessageMq_old(String json) {
logger.info("通知消息:{}", json); logger.info("通知消息:{}", json);
NoticeMessageQDTO messageQDTO = JSONObject.parseObject(json, NoticeMessageQDTO.class); NoticeMessageQDTO messageQDTO = JSONObject.parseObject(json, NoticeMessageQDTO.class);
NoticeMessageTypeEnum messageTypeEnum = NoticeMessageTypeEnum.getByType(messageQDTO.getMessageType()); NoticeMessageTypeEnum messageTypeEnum = NoticeMessageTypeEnum.getByType(messageQDTO.getMessageType());
...@@ -154,11 +155,16 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService { ...@@ -154,11 +155,16 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
noticeMessageService.addOrCreateNoticeMessage(noticeMessageBO); noticeMessageService.addOrCreateNoticeMessage(noticeMessageBO);
//发送企业微信 //发送企业微信
sendMessage(contentList, wxEnterpriseId, staffId, messageTypeEnum, noticeMessageBO.getMessageContent(),messageQDTO.getTitle()); sendMessage(contentList, wxEnterpriseId, staffId, messageTypeEnum, noticeMessageBO.getMessageContent(),messageQDTO.getTitle());
}*/ }
@Override @Override
public void noticeMessageMq(String json) { public void noticeMessageMq(String json) {
if (!ApolloUtils.useMessageCenter()){
logger.info("消息中心-走老版消息通知");
this.noticeMessageMq_old(json);
return;
}
NoticeMessageQDTO messageQDTO = JSONObject.parseObject(json, NoticeMessageQDTO.class); NoticeMessageQDTO messageQDTO = JSONObject.parseObject(json, NoticeMessageQDTO.class);
logger.info("messageType:{},消息中心测试通知消息:{}", messageQDTO.getMessageType(), json); logger.info("messageType:{},消息中心测试通知消息:{}", messageQDTO.getMessageType(), json);
String staffId = null; String staffId = null;
...@@ -214,12 +220,17 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService { ...@@ -214,12 +220,17 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
@Override @Override
public void noticeMessageBatchMq(String json) { public void noticeMessageBatchMq(String json) {
NotifyMessageBatchQDTO notifyMessageBatchQDTO = JSONObject.parseObject(json, NotifyMessageBatchQDTO.class); NotifyMessageBatchQDTO notifyMessageBatchQDTO = JSONObject.parseObject(json, NotifyMessageBatchQDTO.class);
if (!ApolloUtils.useMessageCenter()){
logger.info("消息中心-走老版消息通知");
this.batchSendMessage_old(notifyMessageBatchQDTO);
return;
}
batchSendMessage(notifyMessageBatchQDTO); batchSendMessage(notifyMessageBatchQDTO);
} }
/*消息中心修改此处 /*消息中心修改此处
@Override @Override*/
public ServiceResponse<Void> batchSendMessage(NotifyMessageBatchQDTO notifyMessageBatchQDTO) { public ServiceResponse<Void> batchSendMessage_old(NotifyMessageBatchQDTO notifyMessageBatchQDTO) {
String enterpriseId = notifyMessageBatchQDTO.getEnterpriseId(); String enterpriseId = notifyMessageBatchQDTO.getEnterpriseId();
List<String> storeIdList = notifyMessageBatchQDTO.getStoreIdList(); List<String> storeIdList = notifyMessageBatchQDTO.getStoreIdList();
if (CollectionUtils.isEmpty(storeIdList)) { if (CollectionUtils.isEmpty(storeIdList)) {
...@@ -268,7 +279,7 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService { ...@@ -268,7 +279,7 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
} }
}); });
return ServiceResponse.success(); return ServiceResponse.success();
}*/ }
@Override @Override
......
package com.gic.haoban.manage.service.util;
import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.ConfigService;
public class ApolloUtils {
/**
* 旧的调用发送,是否采用新的消息中心开关1:是 0:否
* @return
*/
public static boolean useMessageCenter() {
Config config = ConfigService.getConfig("COMMON.gic-properties");
String messageCenterSwitch = config.getProperty("messageCenterSwitch", "0");
return "1".equals(messageCenterSwitch);
}
}
...@@ -116,8 +116,8 @@ public class GroupMessageServiceTest { ...@@ -116,8 +116,8 @@ public class GroupMessageServiceTest {
qywxMomentInfoQDTO.setEndTime(1681906519L); qywxMomentInfoQDTO.setEndTime(1681906519L);
qywxMomentInfoQDTO.setCreatorId("wo59NLDQAAbjSBA575NouC1pUYQgCOtw"); qywxMomentInfoQDTO.setCreatorId("wo59NLDQAAbjSBA575NouC1pUYQgCOtw");
qywxMomentInfoQDTO.setPageSize(20); qywxMomentInfoQDTO.setPageSize(20);
ServiceResponse<QywxMomentRespDTO> serviceResponse = qywxSuiteApiService.queryQywxMomentList(qywxMomentInfoQDTO); //ServiceResponse<QywxMomentRespDTO> serviceResponse = qywxSuiteApiService.queryQywxMomentList(qywxMomentInfoQDTO);
System.out.println(JSON.toJSONString(serviceResponse)); //System.out.println(JSON.toJSONString(serviceResponse));
} }
@Test @Test
......
...@@ -124,8 +124,8 @@ public class NotityTest { ...@@ -124,8 +124,8 @@ public class NotityTest {
articleInfo.setPicurl("https://platform-1251519181.cos.ap-shanghai.myqcloud.com/image/newdmwltest/enterprise_common-e1e8b3d46fdb4486ad545aae6cba67a1.png"); articleInfo.setPicurl("https://platform-1251519181.cos.ap-shanghai.myqcloud.com/image/newdmwltest/enterprise_common-e1e8b3d46fdb4486ad545aae6cba67a1.png");
messageDTO.setArticleMessages(Arrays.asList(articleInfo)); messageDTO.setArticleMessages(Arrays.asList(articleInfo));
boolean b = qywxSuiteApiService.sendMessage(corpid, config.getWxSuiteid(), messageDTO); /*boolean b = qywxSuiteApiService.sendMessage(corpid, config.getWxSuiteid(), messageDTO);
System.out.println(b); System.out.println(b);*/
} }
@Test @Test
...@@ -138,7 +138,7 @@ public class NotityTest { ...@@ -138,7 +138,7 @@ public class NotityTest {
search.setSuiteid(config.getWxSuiteid()); search.setSuiteid(config.getWxSuiteid());
search.setChatType("single"); search.setChatType("single");
Date date = DateUtils.addDays(new Date(), -1); Date date = DateUtils.addDays(new Date(), -1);
ServiceResponse<QywxGroupMsgResp> serviceResponse = qywxSuiteApiService.queryQywxGroupMessageList(search); //ServiceResponse<QywxGroupMsgResp> serviceResponse = qywxSuiteApiService.queryQywxGroupMessageList(search);
} }
......
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