Commit cd8c4792 by zhangzhendong

好办消息中心修改

parent 5fe4f80c
package com.gic.haoban.manage.api.dto.qdto;
import java.io.Serializable;
import java.util.Date;
/**
* Created By MBG-GUI-EXTENSION https://github.com/spawpaw/mybatis-generator-gui-extension
* Description:
* 好办消息通知
*
* @author fdh
*/
public class NoticeMessageQDTO implements Serializable {
/**
*
*/
private Long noticeMessageId;
/**
* 企业id
*/
private String enterpriseId;
/**
* 门店id
*/
private String storeId;
/**
* 导购id
*/
private String clerkId;
/**
* 类别 0客户相关、1任务相关、2活动相关、3其他
*/
private Integer categoryType;
/**
* 消息类型
*/
private Integer messageType;
private String templateCode;
/**
* 标题
*/
private String title;
/**
* 描述
*/
private String description;
/**
* 关联的具体业务消息id
*/
private String relationId;
/**
* 消息带的参数信息
*/
private String messageContent;
/**
* 0 未读 1已读
*/
private Integer readFlag;
/**
* 状态 0删除 1正常
*/
private Integer deleteFlag;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
/**
*/
private static final long serialVersionUID = 1L;
public String getTemplateCode() {
return templateCode;
}
public void setTemplateCode(String templateCode) {
this.templateCode = templateCode;
}
/**
* This method returns the value of the database column tab_haoban_notice_message.notice_message_id
*
* @return the value of tab_haoban_notice_message.notice_message_id
*/
public Long getNoticeMessageId() {
return noticeMessageId;
}
/**
* This method sets the value of the database column tab_haoban_notice_message.notice_message_id
*
* @param noticeMessageId the value for tab_haoban_notice_message.notice_message_id
*/
public void setNoticeMessageId(Long noticeMessageId) {
this.noticeMessageId = noticeMessageId;
}
/**
* This method returns the value of the database column tab_haoban_notice_message.enterprise_id
*
* @return the value of tab_haoban_notice_message.enterprise_id
*/
public String getEnterpriseId() {
return enterpriseId;
}
/**
* This method sets the value of the database column tab_haoban_notice_message.enterprise_id
*
* @param enterpriseId the value for tab_haoban_notice_message.enterprise_id
*/
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
/**
* This method returns the value of the database column tab_haoban_notice_message.store_id
*
* @return the value of tab_haoban_notice_message.store_id
*/
public String getStoreId() {
return storeId;
}
/**
* This method sets the value of the database column tab_haoban_notice_message.store_id
*
* @param storeId the value for tab_haoban_notice_message.store_id
*/
public void setStoreId(String storeId) {
this.storeId = storeId;
}
/**
* This method returns the value of the database column tab_haoban_notice_message.clerk_id
*
* @return the value of tab_haoban_notice_message.clerk_id
*/
public String getClerkId() {
return clerkId;
}
/**
* This method sets the value of the database column tab_haoban_notice_message.clerk_id
*
* @param clerkId the value for tab_haoban_notice_message.clerk_id
*/
public void setClerkId(String clerkId) {
this.clerkId = clerkId;
}
/**
* This method returns the value of the database column tab_haoban_notice_message.category_type
*
* @return the value of tab_haoban_notice_message.category_type
*/
public Integer getCategoryType() {
return categoryType;
}
/**
* This method sets the value of the database column tab_haoban_notice_message.category_type
*
* @param categoryType the value for tab_haoban_notice_message.category_type
*/
public void setCategoryType(Integer categoryType) {
this.categoryType = categoryType;
}
/**
* This method returns the value of the database column tab_haoban_notice_message.message_type
*
* @return the value of tab_haoban_notice_message.message_type
*/
public Integer getMessageType() {
return messageType;
}
/**
* This method sets the value of the database column tab_haoban_notice_message.message_type
*
* @param messageType the value for tab_haoban_notice_message.message_type
*/
public void setMessageType(Integer messageType) {
this.messageType = messageType;
}
/**
* This method returns the value of the database column tab_haoban_notice_message.title
*
* @return the value of tab_haoban_notice_message.title
*/
public String getTitle() {
return title;
}
/**
* This method sets the value of the database column tab_haoban_notice_message.title
*
* @param title the value for tab_haoban_notice_message.title
*/
public void setTitle(String title) {
this.title = title;
}
/**
* This method returns the value of the database column tab_haoban_notice_message.description
*
* @return the value of tab_haoban_notice_message.description
*/
public String getDescription() {
return description;
}
/**
* This method sets the value of the database column tab_haoban_notice_message.description
*
* @param description the value for tab_haoban_notice_message.description
*/
public void setDescription(String description) {
this.description = description;
}
/**
* This method returns the value of the database column tab_haoban_notice_message.relation_id
*
* @return the value of tab_haoban_notice_message.relation_id
*/
public String getRelationId() {
return relationId;
}
/**
* This method sets the value of the database column tab_haoban_notice_message.relation_id
*
* @param relationId the value for tab_haoban_notice_message.relation_id
*/
public void setRelationId(String relationId) {
this.relationId = relationId;
}
/**
* This method returns the value of the database column tab_haoban_notice_message.message_content
*
* @return the value of tab_haoban_notice_message.message_content
*/
public String getMessageContent() {
return messageContent;
}
/**
* This method sets the value of the database column tab_haoban_notice_message.message_content
*
* @param messageContent the value for tab_haoban_notice_message.message_content
*/
public void setMessageContent(String messageContent) {
this.messageContent = messageContent;
}
/**
* This method returns the value of the database column tab_haoban_notice_message.read_flag
*
* @return the value of tab_haoban_notice_message.read_flag
*/
public Integer getReadFlag() {
return readFlag;
}
/**
* This method sets the value of the database column tab_haoban_notice_message.read_flag
*
* @param readFlag the value for tab_haoban_notice_message.read_flag
*/
public void setReadFlag(Integer readFlag) {
this.readFlag = readFlag;
}
/**
* This method returns the value of the database column tab_haoban_notice_message.delete_flag
*
* @return the value of tab_haoban_notice_message.delete_flag
*/
public Integer getDeleteFlag() {
return deleteFlag;
}
/**
* This method sets the value of the database column tab_haoban_notice_message.delete_flag
*
* @param deleteFlag the value for tab_haoban_notice_message.delete_flag
*/
public void setDeleteFlag(Integer deleteFlag) {
this.deleteFlag = deleteFlag;
}
/**
* This method returns the value of the database column tab_haoban_notice_message.create_time
*
* @return the value of tab_haoban_notice_message.create_time
*/
public Date getCreateTime() {
return createTime;
}
/**
* This method sets the value of the database column tab_haoban_notice_message.create_time
*
* @param createTime the value for tab_haoban_notice_message.create_time
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
* This method returns the value of the database column tab_haoban_notice_message.update_time
*
* @return the value of tab_haoban_notice_message.update_time
*/
public Date getUpdateTime() {
return updateTime;
}
/**
* This method sets the value of the database column tab_haoban_notice_message.update_time
*
* @param updateTime the value for tab_haoban_notice_message.update_time
*/
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
\ No newline at end of file
......@@ -29,12 +29,16 @@ public enum NoticeMessageTypeEnum {
STORE_ACCOUNT(3001, "账号申请", NoticeMessageCategoryTypeEnum.OTHER.getType(), "store_account", "/pages/route/index?pageType=", "store_relate_store_record_list"),
//
MEMBER_FACE(3002, "账号申请", NoticeMessageCategoryTypeEnum.OTHER.getType(), "member_face", "/pages/route/index?pageType=", "hbapp_customer_edit_tag"),
//下面两个使用staff发送
STORE_ACCOUNT_REFUSE(3010, "账号申请", NoticeMessageCategoryTypeEnum.OTHER.getType(), "store_account_refuse", "/pages/route/index?pageType=", "store_relate_store_record_list"),
STORE_ACCOUNT_AGREE(3011, "账号申请", NoticeMessageCategoryTypeEnum.OTHER.getType(), "store_account_agree", "/pages/route/index?pageType=", "store_relate_store_record_list"),
CLERK_ADD_REFUSE(3020, "导购新增通知", NoticeMessageCategoryTypeEnum.OTHER.getType(), "clerk_add_refuse", "/pages/route/index?pageType=", "store_relate_store_record_list"),
CLERK_ADD_AGREE(3021, "导购新增通知", NoticeMessageCategoryTypeEnum.OTHER.getType(), "clerk_add_agree", "/pages/route/index?pageType=", "store_relate_store_record_list"),
//
CLERK_DEL_REFUSE(3022, "导购删除通知", NoticeMessageCategoryTypeEnum.OTHER.getType(), "clerk_del_refuse", "/pages/route/index?pageType=", "store_relate_store_record_list"),
CLERK_DEL_AGREE(3023, "导购删除通知", NoticeMessageCategoryTypeEnum.OTHER.getType(), "clerk_del_agree", "/pages/route/index?pageType=", "store_relate_store_record_list"),
STORE_EDIT_REFUSE(3024, "门店信息修改通知", NoticeMessageCategoryTypeEnum.OTHER.getType(), "store_edit_refuse", "/pages/route/index?pageType=", "store_detail"),
......@@ -52,6 +56,7 @@ public enum NoticeMessageTypeEnum {
CUSTOMER_UNBIND(3054, "客户变动通知", NoticeMessageCategoryTypeEnum.OTHER.getType(), "customer_unbind", "/pages/route/index?pageType=", "hbapp_customer_list"),
CUSTOMER_ORDER_CREATE(4001, "客户下单通知", NoticeMessageCategoryTypeEnum.CUSTOMER.getType(), "customer_order_create", "/pages/route/index?pageType=", "hbapp_customer_order_detail"),
//
CUSTOMER_ORDER_REFUND(4002, "客户退单通知", NoticeMessageCategoryTypeEnum.CUSTOMER.getType(), "customer_order_refund", "/pages/route/index?pageType=", "hbapp_withdraw_list"),
CUSTOMER_ORDER_LOOK(4003, "客户浏览通知", NoticeMessageCategoryTypeEnum.CUSTOMER.getType(), "customer_order_look", "/pages/route/index?pageType=", "hbapp_customer_look_goods"),
CUSTOMER_GET_COUPON(4004, "客户领券通知", NoticeMessageCategoryTypeEnum.CUSTOMER.getType(), "customer_get_coupon", "/pages/route/index?pageType=", "hbapp_customer_detail"),
......@@ -66,7 +71,7 @@ public enum NoticeMessageTypeEnum {
REFUND_DELIVER(5013, "买家寄出退换货提醒", NoticeMessageCategoryTypeEnum.REFUND.getType(), "refund_deliver", "/pages/route/index?pageType=", "hbapp_order_center"),
//
MATERIAL_NEW_NOTIFY(6001, "素材上新通知", NoticeMessageCategoryTypeEnum.MATERIAL.getType(), "material_new_notify", "/pages/route/index?pageType=", "hbapp_material_center"),
MATERIAL_REPORT_NOTIFY(6002, "素材周报/月报通知", NoticeMessageCategoryTypeEnum.MATERIAL.getType(), "material_week_notify", "/pages/route/index?pageType=", "hbapp_mate_report"),
......
......@@ -5,6 +5,7 @@ import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.haoban.manage.api.dto.notify.dto.NoticeMessageInfoDTO;
import com.gic.haoban.manage.api.dto.notify.qdto.NotifyMessageBatchQDTO;
import com.gic.haoban.manage.api.dto.qdto.NoticeMessageQDTO;
import java.util.List;
......@@ -82,4 +83,12 @@ public interface NoticeMessageApiService {
*/
public ServiceResponse<Boolean> updateWriteFlagByClerkId(String enterpriseId, String clerkId, int categoryType);
/**
* 新增好办内部通知
*
* @param qdto
* @return
*/
public ServiceResponse<Boolean> addOrCreateNoticeMessage(List<NoticeMessageQDTO> qdto);
}
\ No newline at end of file
......@@ -196,6 +196,12 @@
<artifactId>gic-order-api</artifactId>
<version>${gic-order-api}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-message-center-api</artifactId>
<version>${gic-message-center-api}</version>
</dependency>
</dependencies>
<build>
......
package com.gic.haoban.manage.service.service.content.adaptor;
import com.alibaba.fastjson.JSON;
import com.gic.commons.util.UniqueIdUtils;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
......@@ -15,7 +16,9 @@ import com.gic.haoban.manage.service.pojo.bo.content.context.PotentialCustomerNo
import com.gic.haoban.manage.service.service.ClerkMainStoreRelatedService;
import com.gic.haoban.manage.service.service.StaffClerkRelationService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.haoban.manage.service.service.message.NoticeMessageHandler;
import com.gic.haoban.manage.service.service.notify.NoticeMessageService;
import com.gic.message.center.api.subcribe.model.NoticeMessageForm;
import com.gic.wechat.api.dto.qywx.ItemDTO;
import com.gic.wechat.api.dto.qywx.QywxXcxSendMessageDTO;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
......@@ -28,6 +31,7 @@ import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -60,6 +64,8 @@ public class PotentialCustomerNotifyBuilder {
private Config config;
@Autowired
private StaffApiService staffApiService;
@Autowired
private NoticeMessageHandler noticeMessageHandler;
/**
* 获取企业下所有导购id
......@@ -189,10 +195,23 @@ public class PotentialCustomerNotifyBuilder {
log.info("企业信息不存在 {}", staffClerkRelation.getWxEnterpriseId());
continue;
}
/* 消息中心修改此处
QywxXcxSendMessageDTO messageDTO = this.buildApplicationMessage(staffClerkRelation, wxEnterpriseQwDTO,
customerStaticsBOMap.get(staffClerkRelation.getClerkId()).getNum(), context.buildExtendParams(staffClerkRelation.getStoreId(), staffClerkRelation.getClerkId()));
boolean sendMessage = qywxSuiteApiService.sendMessage(wxEnterpriseQwDTO.getThirdCorpid(), config.getWxSuiteid(), messageDTO);
log.info("发送销售线索应用消息结果 {}", sendMessage);
log.info("发送销售线索应用消息结果 {}", sendMessage);*/
Map<String, String> variableMap = new HashMap<>();
variableMap.put("memberNum", customerStaticsBOMap.get(staffClerkRelation.getClerkId()).getNum().toString());
variableMap.put("page", NoticeMessageUtil.buildMiniAppUrl(NoticeMessageTypeEnum.POTENTIAL_CUSTOMER_NOTIFY, context.buildExtendParams(staffClerkRelation.getStoreId(), staffClerkRelation.getClerkId())));
noticeMessageHandler.sendMessage(NoticeMessageForm.builder()
.messageCode("等模版code")
.mqRouterCode("等模版code")
.businessId("-1")
.createTime(new Date())
.enterpriseId(context.getEnterpriseId())
.uniqueKey(UniqueIdUtils.uniqueLongHex())
.userIdList(Collections.singletonList(staffClerkRelation.getClerkId()))
.variableMap(variableMap).build());
}
}
......
package com.gic.haoban.manage.service.service.content.impl;
import com.alibaba.fastjson.JSON;
import com.gic.commons.util.UniqueIdUtils;
import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum;
import com.gic.haoban.manage.api.util.notify.NoticeMessageUtil;
import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.gic.haoban.manage.service.pojo.bo.NoticeMessageBO;
......@@ -12,7 +15,10 @@ import com.gic.haoban.manage.service.service.StaffService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.haoban.manage.service.service.content.MaterialReportService;
import com.gic.haoban.manage.service.service.content.adaptor.MaterialReportBuilder;
import com.gic.haoban.manage.service.service.message.NoticeMessageHandler;
import com.gic.haoban.manage.service.service.notify.NoticeMessageService;
import com.gic.message.center.api.subcribe.model.NoticeMessageForm;
import com.gic.wechat.api.dto.qywx.QywxNewsArticleMessageDTO;
import com.gic.wechat.api.dto.qywx.QywxNewsSendMessageDTO;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import lombok.extern.slf4j.Slf4j;
......@@ -20,7 +26,12 @@ import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Author MUSI
......@@ -48,6 +59,9 @@ public class MaterialReportServiceImpl implements MaterialReportService {
@Autowired
private Config config;
@Autowired
private NoticeMessageHandler noticeMessageHandler;
/**
* 素材周报/月报
......@@ -97,7 +111,25 @@ public class MaterialReportServiceImpl implements MaterialReportService {
return;
}
log.info("发送企业图文消息参数{}", JSON.toJSONString(newsSendMessageDTO));
/*消息中心修改此处
boolean result = qywxSuiteApiService.sendMessage(qwDTO.getThirdCorpid(), config.getWxSuiteid(), newsSendMessageDTO);
log.info("成员{}发送素材企微使用报告结果 {}", staffId, result);
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());
noticeMessageHandler.sendMessage(NoticeMessageForm.builder()
.messageCode("等模版code")
.mqRouterCode("等模版code")
.businessId("-1")
.createTime(new Date())
.enterpriseId(context.getEnterpriseId())
.uniqueKey(UniqueIdUtils.uniqueLongHex())
.userIdList(context.getClerkId() == null ? new ArrayList<>() : Collections.singletonList(context.getClerkId()))
.variableMap(variableMap).build());
}
}
......@@ -263,7 +263,8 @@ public class PotentialCustomerServiceImpl implements PotentialCustomerService {
// 区经 忽略
potentialCustomerNotifyBuilder.filterAreaManage(context);
// 构建应用内消息
potentialCustomerNotifyBuilder.sendHaoBanNotifyMessage(context);
/*消息中心修改此处
potentialCustomerNotifyBuilder.sendHaoBanNotifyMessage(context);*/
// 如果该导购id是成员在主门店时的导购id 发送应用消息
// 如果本批数据中无成员主门店数据 则不发送
potentialCustomerNotifyBuilder.sendApplicationMessage(context);
......
package com.gic.haoban.manage.service.service.message;
import com.alibaba.fastjson.JSONObject;
import com.gic.haoban.manage.service.service.notify.out.NoticeMessageApiServiceImpl;
import com.gic.message.center.api.subcribe.model.NoticeMessageForm;
import org.slf4j.Logger;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import static org.slf4j.LoggerFactory.getLogger;
/**
* @description: 企业微信通知消息发送处理类
* @author: 巴弗
* @createDate: 2023/4/21 14:03
*/
@Service
public class NoticeMessageHandler {
private static final Logger logger = getLogger(NoticeMessageHandler.class);
/**
* 发送小程序消息
*/
public void sendMessage(NoticeMessageForm noticeMessageForm){
logger.info("消息中心发送消息实体:{}", JSONObject.toJSONString(noticeMessageForm));
}
}
......@@ -12,15 +12,20 @@ import cn.hutool.core.collection.ListUtil;
import com.alibaba.fastjson.JSON;
import com.gic.clerk.api.dto.ClerkListDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.GICMQClientUtil;
import com.gic.commons.util.UniqueIdUtils;
import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.dto.notify.dto.NotifyMessageMQDTO;
import com.gic.haoban.manage.api.dto.notify.qdto.NotifyMessageBatchQDTO;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.StaffClerkRelationApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
import com.gic.haoban.manage.api.util.notify.NoticeMessageUtil;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise;
import com.gic.haoban.manage.service.service.WxEnterpriseRelatedService;
import com.gic.haoban.manage.service.service.message.NoticeMessageHandler;
import com.gic.message.center.api.subcribe.model.NoticeMessageForm;
import com.gic.wechat.api.dto.qywx.QywxTemplateCardSendMessageDTO;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
......@@ -92,10 +97,15 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
@Autowired
private ClerkService clerkService;
@Autowired
private NoticeMessageHandler noticeMessageHandler;
/*消息中心修改此处
@Override
public void noticeMessageMq(String json) {
logger.info("通知消息:{}", json);
NoticeMessageQDTO messageQDTO = JSONObject.parseObject(json, NoticeMessageQDTO.class);
NoticeMessageTypeEnum messageTypeEnum = NoticeMessageTypeEnum.getByType(messageQDTO.getMessageType());
if (messageTypeEnum == null) {
logger.error("无消息模板:{}", json);
......@@ -144,6 +154,53 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
noticeMessageService.addOrCreateNoticeMessage(noticeMessageBO);
//发送企业微信
sendMessage(contentList, wxEnterpriseId, staffId, messageTypeEnum, noticeMessageBO.getMessageContent(),messageQDTO.getTitle());
}*/
@Override
public void noticeMessageMq(String json) {
NoticeMessageQDTO messageQDTO = JSONObject.parseObject(json, NoticeMessageQDTO.class);
logger.info("messageType:{},消息中心测试通知消息:{}", messageQDTO.getMessageType(), json);
String staffId = null;
StaffClerkRelationDTO clerkRelationDTO = null;
if (StringUtils.isNotBlank(messageQDTO.getStaffId())) {
TabHaobanStaff haobanStaff = staffService.selectById(messageQDTO.getStaffId());
staffId = haobanStaff != null ? haobanStaff.getStaffId() : null;
}
if (StringUtils.isNotEmpty(messageQDTO.getClerkId())) {
clerkRelationDTO = staffClerkRelationService.getByClerkId(messageQDTO.getClerkId());
}
if (staffId == null && clerkRelationDTO == null) {
logger.info("没有导购:{}", messageQDTO.getClerkId());
return;
}
try {
Map<String, String> variableMap = messageQDTO.getContentMap();
variableMap.put("pageParams", JSONObject.toJSONString(messageQDTO.getExtendContent()));
variableMap.put("templateTitle", messageQDTO.getTitle());
NoticeMessageForm build = NoticeMessageForm.builder()
.messageCode("等模版code")
.mqRouterCode("等模版code")
.businessId(messageQDTO.getOptTargetId())
.createTime(new Date())
.enterpriseId(messageQDTO.getEnterpriseId())
.uniqueKey(UniqueIdUtils.uniqueLongHex())
.variableMap(variableMap).build();
if (clerkRelationDTO != null){
build.setUserIdList(Collections.singletonList(clerkRelationDTO.getClerkId()));
} else {
build.setStaffIdList(Collections.singletonList(staffId));
}
noticeMessageHandler.sendMessage(build);
} catch (Exception e) {
logger.error("发送消息通知失败",e);
}
}
@Override
......@@ -157,6 +214,7 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
batchSendMessage(notifyMessageBatchQDTO);
}
/*消息中心修改此处
@Override
public ServiceResponse<Void> batchSendMessage(NotifyMessageBatchQDTO notifyMessageBatchQDTO) {
String enterpriseId = notifyMessageBatchQDTO.getEnterpriseId();
......@@ -182,6 +240,7 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
logger.info("成员关联列表为空");
return ServiceResponse.success();
}
NoticeMessageTypeEnum messageTypeEnum = NoticeMessageTypeEnum.getByType(notifyMessageBatchQDTO.getMessageType());
if (messageTypeEnum == null) {
logger.error("无消息模板:{}", JSON.toJSONString(notifyMessageBatchQDTO));
......@@ -207,9 +266,74 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
}
});
return ServiceResponse.success();
}*/
@Override
public ServiceResponse<Void> batchSendMessage(NotifyMessageBatchQDTO notifyMessageBatchQDTO) {
logger.info("消息中心测试通知消息:{}", JSONObject.toJSONString(notifyMessageBatchQDTO));
String enterpriseId = notifyMessageBatchQDTO.getEnterpriseId();
List<String> storeIdList = notifyMessageBatchQDTO.getStoreIdList();
if (CollectionUtils.isEmpty(storeIdList)) {
logger.info("门店列表为空");
return ServiceResponse.success();
}
int count = wxEnterpriseRelatedService.getRelationCount(enterpriseId);
if (count == 0) {
logger.info("商户未关联好办或都已停用enterpriseId={}", enterpriseId);
return ServiceResponse.success();
}
List<String> clerkIdList = clerkService.getclerkListByStoreIds(storeIdList);
if (CollectionUtils.isEmpty(clerkIdList)) {
logger.info("门店导购列表为空");
return ServiceResponse.success();
}
List<StaffClerkRelationDTO> relationList = staffClerkRelationService.listByClerkIds(clerkIdList);
if (CollectionUtils.isEmpty(relationList)) {
logger.info("成员关联列表为空");
return ServiceResponse.success();
}
try {
//TODO 这里有个回调未处理
Map<String, String> variableMap = notifyMessageBatchQDTO.getContentMap();
variableMap.put("pageParams", JSONObject.toJSONString(notifyMessageBatchQDTO.getExtendContent()));
variableMap.put("templateTitle", notifyMessageBatchQDTO.getTitle());
noticeMessageHandler.sendMessage(NoticeMessageForm.builder()
.messageCode("等模版code")
.mqRouterCode("等模版code")
.businessId(notifyMessageBatchQDTO.getOptTargetId())
.createTime(new Date())
.enterpriseId(notifyMessageBatchQDTO.getEnterpriseId())
.uniqueKey(UniqueIdUtils.uniqueLongHex())
.userIdList(relationList.stream().map(StaffClerkRelationDTO::getClerkId).distinct().collect(Collectors.toList()))
.variableMap(variableMap).build());
} catch (Exception e) {
logger.error("发送消息通知失败",e);
}
return ServiceResponse.success();
}
private String getUrlParams(Map<String, Object> extendContent) {
String data = extendContent != null ? JSONObject.toJSONString(extendContent) : null;
if (StringUtils.isNotBlank(data)) {
try {
data = URLEncoder.encode(data, StandardCharsets.UTF_8.name());
} catch (UnsupportedEncodingException e) {
logger.error(e.getMessage());
}
}
return data;
}
private void sendMessage(NotifyMessageBatchQDTO notifyMessageBatchQDTO, List<StaffClerkRelationDTO> list,Set<String> userIdSet, WxEnterpriseQwDTO qwDTO) {
//企业微信模板
List<TemplateContentBO> contentList = getDescriotion(notifyMessageBatchQDTO);
//好办模板
......@@ -265,6 +389,7 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
appUrl += messageTypeEnum.getPageType();
}
appUrl += "&data=" + data;
messageDTO.setAppid(config.getAppid());
messageDTO.setAgentId(Integer.parseInt(qwDTO.getAgentId()));
messageDTO.setAgentName(qwDTO.getAgentName());
......@@ -324,6 +449,13 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
return ServiceResponse.success(true);
}
@Override
public ServiceResponse<Boolean> addOrCreateNoticeMessage(List<com.gic.haoban.manage.api.dto.qdto.NoticeMessageQDTO> qdto) {
noticeMessageService.addNoticeMessageBatch(EntityUtil.changeEntityListByJSON(NoticeMessageBO.class, qdto));
return ServiceResponse.success();
}
/**
* 获取详情
*
......
......@@ -565,6 +565,7 @@ public class MessageApiServiceImpl implements MessageApiService {
}
@Override
@Deprecated
public com.gic.api.base.commons.ServiceResponse<Void> sendPreMessage(String enterpriseId, String storeId,
String message) {
log.info("线下预约通知,storeId={}", storeId);
......
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