Commit bdb362e5 by 王祖波

好办消息通知

parent 35055d63
package com.gic.haoban.manage.api.dto.notify.dto;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* Created by wangzubo on 2023/3/13.
*/
public class NotifyMessageMQDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 导购id列表
*/
private List<String> clerkIdList;
/**
* 通知类型
*/
private String templateCode;
/**
* 拓展内容
*/
private Map<String, Object> extendContent;
/**
* 结果 1成功0失败
*/
private Integer result;
public List<String> getClerkIdList() {
return clerkIdList;
}
public void setClerkIdList(List<String> clerkIdList) {
this.clerkIdList = clerkIdList;
}
public String getTemplateCode() {
return templateCode;
}
public void setTemplateCode(String templateCode) {
this.templateCode = templateCode;
}
public Map<String, Object> getExtendContent() {
return extendContent;
}
public void setExtendContent(Map<String, Object> extendContent) {
this.extendContent = extendContent;
}
public Integer getResult() {
return result;
}
public void setResult(Integer result) {
this.result = result;
}
}
...@@ -16,6 +16,8 @@ public class NoticeMessageQDTO implements Serializable { ...@@ -16,6 +16,8 @@ public class NoticeMessageQDTO implements Serializable {
private String optTargetId; private String optTargetId;
private int messageType; private int messageType;
private String templateCode; private String templateCode;
private String title;
private Map<String, String> contentMap; private Map<String, String> contentMap;
public NoticeMessageQDTO() { public NoticeMessageQDTO() {
...@@ -109,6 +111,14 @@ public class NoticeMessageQDTO implements Serializable { ...@@ -109,6 +111,14 @@ public class NoticeMessageQDTO implements Serializable {
this.templateCode = templateCode; this.templateCode = templateCode;
} }
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Map<String, String> getContentMap() { public Map<String, String> getContentMap() {
return contentMap; return contentMap;
} }
......
package com.gic.haoban.manage.api.dto.notify.qdto;
import java.util.List;
/**
* Created by wangzubo on 2023/3/13.
*/
public class NotifyMessageBatchQDTO extends NoticeMessageQDTO{
private static final long serialVersionUID = 1L;
private List<String> storeIdList;
public List<String> getStoreIdList() {
return storeIdList;
}
public void setStoreIdList(List<String> storeIdList) {
this.storeIdList = storeIdList;
}
}
...@@ -10,6 +10,7 @@ public enum NoticeMessageCategoryTypeEnum { ...@@ -10,6 +10,7 @@ public enum NoticeMessageCategoryTypeEnum {
CUSTOMER(0, "客户相关"), CUSTOMER(0, "客户相关"),
TASK(1, "任务相关"), TASK(1, "任务相关"),
ACTIVITY(2, "活动相关"), ACTIVITY(2, "活动相关"),
MATERIAL(4, "素材相关"),
OTHER(3, "其它"),; OTHER(3, "其它"),;
private int type; private int type;
private String name; private String name;
......
...@@ -57,6 +57,10 @@ public enum NoticeMessageTypeEnum { ...@@ -57,6 +57,10 @@ public enum NoticeMessageTypeEnum {
CUSTOMER_GET_COUPON(4004, "客户领券通知", NoticeMessageCategoryTypeEnum.CUSTOMER.getType(), "customer_get_coupon", "/pages/route/index?pageType=", "hbapp_customer_detail"), CUSTOMER_GET_COUPON(4004, "客户领券通知", NoticeMessageCategoryTypeEnum.CUSTOMER.getType(), "customer_get_coupon", "/pages/route/index?pageType=", "hbapp_customer_detail"),
CUSTOMER_APPLY_ORDER_REFUND(4005, "客户申请退单通知", NoticeMessageCategoryTypeEnum.CUSTOMER.getType(), "customer_apply_order_refund", "/pages/route/index?pageType=", "hbapp_customer_order_detail"), CUSTOMER_APPLY_ORDER_REFUND(4005, "客户申请退单通知", NoticeMessageCategoryTypeEnum.CUSTOMER.getType(), "customer_apply_order_refund", "/pages/route/index?pageType=", "hbapp_customer_order_detail"),
CUSTOMER_SUCCESS_ORDER_REFUND(4006, "客户成功退单通知", NoticeMessageCategoryTypeEnum.CUSTOMER.getType(), "customer_success_order_refund", "/pages/route/index?pageType=", "hbapp_user_bill_detail"), CUSTOMER_SUCCESS_ORDER_REFUND(4006, "客户成功退单通知", NoticeMessageCategoryTypeEnum.CUSTOMER.getType(), "customer_success_order_refund", "/pages/route/index?pageType=", "hbapp_user_bill_detail"),
// todo pageType
MATERIAL_NEW_NOTIFY(5001, "素材上新通知", NoticeMessageCategoryTypeEnum.MATERIAL.getType(), "material_new_notify", "/pages/route/index?pageType=", "hbapp_customer_list"),
; ;
/** /**
* 消息类型 * 消息类型
......
...@@ -3,6 +3,8 @@ package com.gic.haoban.manage.api.service; ...@@ -3,6 +3,8 @@ package com.gic.haoban.manage.api.service;
import com.gic.api.base.commons.ServiceResponse; import com.gic.api.base.commons.ServiceResponse;
import com.gic.haoban.manage.api.dto.QywxCallBackDTO; import com.gic.haoban.manage.api.dto.QywxCallBackDTO;
import java.util.List;
/** /**
* Created by tgs on 2020/2/20. * Created by tgs on 2020/2/20.
*/ */
......
...@@ -4,6 +4,9 @@ import com.gic.api.base.commons.BasePageInfo; ...@@ -4,6 +4,9 @@ import com.gic.api.base.commons.BasePageInfo;
import com.gic.api.base.commons.Page; import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse; 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.dto.NoticeMessageInfoDTO;
import com.gic.haoban.manage.api.dto.notify.qdto.NotifyMessageBatchQDTO;
import java.util.List;
/** /**
* Created 2021/12/17. * Created 2021/12/17.
...@@ -26,6 +29,20 @@ public interface NoticeMessageApiService { ...@@ -26,6 +29,20 @@ public interface NoticeMessageApiService {
public void run(String json); public void run(String json);
/** /**
* 消息接收 发送消息
* "routerName": "haobanNoticeMessageBatch"
* @param json
*/
void noticeMessageBatchMq(String json);
/**
* 批量发送实现
* @param notifyMessageBatchQDTO
* @return
*/
ServiceResponse<Void> batchSendMessage(NotifyMessageBatchQDTO notifyMessageBatchQDTO);
/**
* 消息分页 * 消息分页
*1 *1
* @param enterpriseId * @param enterpriseId
......
package com.gic.haoban.manage.api.service.notify;
import com.gic.api.base.commons.ServiceResponse;
import java.util.List;
public interface NoticeMessageMQApiService {
ServiceResponse<Void> receviceSendMessage(String enterpriseId, List<String> storeIdList);
}
\ No newline at end of file
...@@ -26,6 +26,8 @@ public class NoticeMessageUtil { ...@@ -26,6 +26,8 @@ public class NoticeMessageUtil {
private static final String NOTICE_MESSAGE = "haobanNoticeMessage"; private static final String NOTICE_MESSAGE = "haobanNoticeMessage";
private static final String NOTICE_MESSAGE_BATCH = "haobanNoticeMessageBatch";
/** /**
* 发送消息 * 发送消息
* *
......
...@@ -20,6 +20,8 @@ public interface NoticeMessageMapper { ...@@ -20,6 +20,8 @@ public interface NoticeMessageMapper {
*/ */
int insertSelective(TabNoticeMessage record); int insertSelective(TabNoticeMessage record);
int insertBatch(@Param("records")List<TabNoticeMessage> record);
/** /**
*/ */
TabNoticeMessage selectByPrimaryKey(Long noticeMessageId); TabNoticeMessage selectByPrimaryKey(Long noticeMessageId);
......
...@@ -5,6 +5,8 @@ import com.gic.api.base.commons.Page; ...@@ -5,6 +5,8 @@ import com.gic.api.base.commons.Page;
import com.gic.haoban.manage.service.pojo.bo.NoticeMessageBO; import com.gic.haoban.manage.service.pojo.bo.NoticeMessageBO;
import com.gic.haoban.manage.service.pojo.bo.PendingTaskBO; import com.gic.haoban.manage.service.pojo.bo.PendingTaskBO;
import java.util.List;
/** /**
* Created 2021/12/15. * Created 2021/12/15.
* *
...@@ -20,6 +22,8 @@ public interface NoticeMessageService { ...@@ -20,6 +22,8 @@ public interface NoticeMessageService {
*/ */
public boolean addOrCreateNoticeMessage(NoticeMessageBO messageBO); public boolean addOrCreateNoticeMessage(NoticeMessageBO messageBO);
void addNoticeMessageBatch(List<NoticeMessageBO> list);
/** /**
* 分页查询消息 * 分页查询消息
* *
......
...@@ -11,6 +11,7 @@ import com.gic.haoban.manage.service.pojo.bo.NoticeMessageBO; ...@@ -11,6 +11,7 @@ import com.gic.haoban.manage.service.pojo.bo.NoticeMessageBO;
import com.gic.haoban.manage.service.pojo.bo.PendingTaskBO; import com.gic.haoban.manage.service.pojo.bo.PendingTaskBO;
import com.gic.haoban.manage.service.service.notify.NoticeMessageService; import com.gic.haoban.manage.service.service.notify.NoticeMessageService;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -43,6 +44,20 @@ public class NoticeMessageServiceImpl implements NoticeMessageService { ...@@ -43,6 +44,20 @@ public class NoticeMessageServiceImpl implements NoticeMessageService {
} }
@Override @Override
public void addNoticeMessageBatch(List<NoticeMessageBO> list) {
if (CollectionUtils.isEmpty(list)) {
return;
}
List<TabNoticeMessage> noticeMessageList = EntityUtil.changeEntityListByJSON(TabNoticeMessage.class, list);
for (TabNoticeMessage noticeMessage : noticeMessageList) {
noticeMessage.setNoticeMessageId(UniqueIdUtils.uniqueLong());
noticeMessage.setCreateTime(new Date());
noticeMessage.setUpdateTime(new Date());
}
noticeMessageMapper.insertBatch(noticeMessageList);
}
@Override
public Page<NoticeMessageBO> pageNoticeMessage(String enterpriseId, String storeId, String clerkId, int categoryType, BasePageInfo pageInfo) { public Page<NoticeMessageBO> pageNoticeMessage(String enterpriseId, String storeId, String clerkId, int categoryType, BasePageInfo pageInfo) {
PageHelper.startPage(pageInfo); PageHelper.startPage(pageInfo);
List<TabNoticeMessage> list = noticeMessageMapper.listNoticeMessage(enterpriseId, storeId, clerkId, categoryType); List<TabNoticeMessage> list = noticeMessageMapper.listNoticeMessage(enterpriseId, storeId, clerkId, categoryType);
......
...@@ -10,6 +10,18 @@ import java.util.List; ...@@ -10,6 +10,18 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
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.GICMQClientUtil;
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.service.service.WxEnterpriseRelatedService;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -74,6 +86,12 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService { ...@@ -74,6 +86,12 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
@Autowired @Autowired
private StaffService staffService; private StaffService staffService;
@Autowired
private WxEnterpriseRelatedService wxEnterpriseRelatedService;
@Autowired
private ClerkService clerkService;
@Override @Override
public void noticeMessageMq(String json) { public void noticeMessageMq(String json) {
logger.info("通知消息:{}", json); logger.info("通知消息:{}", json);
...@@ -117,7 +135,7 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService { ...@@ -117,7 +135,7 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
noticeMessageBO.setMessageType(messageQDTO.getMessageType()); noticeMessageBO.setMessageType(messageQDTO.getMessageType());
noticeMessageBO.setClerkId(messageQDTO.getClerkId() != null ? messageQDTO.getClerkId() : "-1"); noticeMessageBO.setClerkId(messageQDTO.getClerkId() != null ? messageQDTO.getClerkId() : "-1");
noticeMessageBO.setStoreId(clerkRelationDTO != null ? clerkRelationDTO.getStoreId() : "-1"); noticeMessageBO.setStoreId(clerkRelationDTO != null ? clerkRelationDTO.getStoreId() : "-1");
noticeMessageBO.setTitle(messageTypeEnum.getName()); noticeMessageBO.setTitle(StringUtils.isNotBlank(messageQDTO.getTitle())?messageQDTO.getTitle():messageTypeEnum.getName());
noticeMessageBO.setTemplateCode(messageTypeEnum.getTemplateCode()); noticeMessageBO.setTemplateCode(messageTypeEnum.getTemplateCode());
noticeMessageBO.setDescription(haobanNotice); noticeMessageBO.setDescription(haobanNotice);
noticeMessageBO.setEnterpriseId(messageQDTO.getEnterpriseId()); noticeMessageBO.setEnterpriseId(messageQDTO.getEnterpriseId());
...@@ -125,7 +143,7 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService { ...@@ -125,7 +143,7 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
noticeMessageBO.setMessageContent(messageQDTO.getExtendContent() != null ? JSONObject.toJSONString(messageQDTO.getExtendContent()) : null); noticeMessageBO.setMessageContent(messageQDTO.getExtendContent() != null ? JSONObject.toJSONString(messageQDTO.getExtendContent()) : null);
noticeMessageService.addOrCreateNoticeMessage(noticeMessageBO); noticeMessageService.addOrCreateNoticeMessage(noticeMessageBO);
//发送企业微信 //发送企业微信
sendMessage(contentList, wxEnterpriseId, staffId, messageTypeEnum, noticeMessageBO.getMessageContent()); sendMessage(contentList, wxEnterpriseId, staffId, messageTypeEnum, noticeMessageBO.getMessageContent(),messageQDTO.getTitle());
} }
@Override @Override
...@@ -134,6 +152,135 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService { ...@@ -134,6 +152,135 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
} }
@Override @Override
public void noticeMessageBatchMq(String json) {
NotifyMessageBatchQDTO notifyMessageBatchQDTO = JSONObject.parseObject(json, NotifyMessageBatchQDTO.class);
batchSendMessage(notifyMessageBatchQDTO);
}
@Override
public ServiceResponse<Void> batchSendMessage(NotifyMessageBatchQDTO 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();
}
NoticeMessageTypeEnum messageTypeEnum = NoticeMessageTypeEnum.getByType(notifyMessageBatchQDTO.getMessageType());
if (messageTypeEnum == null) {
logger.error("无消息模板:{}", JSON.toJSONString(notifyMessageBatchQDTO));
return ServiceResponse.success();
}
notifyMessageBatchQDTO.setTemplateCode(messageTypeEnum.getTemplateCode());
Map<String, List<StaffClerkRelationDTO>> map = relationList.stream().collect(Collectors.groupingBy(StaffClerkRelationDTO::getWxEnterpriseId));
map.forEach((wxEnterpriseId,v)->{
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
if (qwDTO == null) {
logger.info("企业为空:{}",wxEnterpriseId);
return;
}
List<List<StaffClerkRelationDTO>> listList = ListUtil.split(v, 1000);
listList.forEach(list->{
sendMessage(notifyMessageBatchQDTO, list, qwDTO);
});
});
return ServiceResponse.success();
}
private void sendMessage(NotifyMessageBatchQDTO notifyMessageBatchQDTO, List<StaffClerkRelationDTO> list, WxEnterpriseQwDTO qwDTO) {
//企业微信模板
List<TemplateContentBO> contentList = getDescriotion(notifyMessageBatchQDTO);
//好办模板
String haobanNotice = getHaobanNotice(notifyMessageBatchQDTO);
//模板不存在
if (CollectionUtils.isEmpty(contentList) || StringUtils.isBlank(haobanNotice)) {
logger.info("没有模板,无法发送消息:{}", notifyMessageBatchQDTO.getTemplateCode());
return;
}
NoticeMessageTypeEnum messageTypeEnum = NoticeMessageTypeEnum.getByType(notifyMessageBatchQDTO.getMessageType());
if (messageTypeEnum == null) {
logger.error("无消息模板:{}", JSON.toJSONString(notifyMessageBatchQDTO));
return;
}
List<String> wxUserIdList = new ArrayList<>();
List<NoticeMessageBO> noticeMessageBOList = new ArrayList<>();
for (StaffClerkRelationDTO relationDTO : list) {
String wxUserId = relationDTO.getQwUserId() ;
if(qwDTO.needOpenUserId3th()) {
wxUserId = relationDTO.getOpenUserId() ;
}
wxUserIdList.add(wxUserId);
//消息组装 新增消息
NoticeMessageBO noticeMessageBO = new NoticeMessageBO();
noticeMessageBO.setCategoryType(messageTypeEnum.getCategory());
noticeMessageBO.setMessageType(notifyMessageBatchQDTO.getMessageType());
noticeMessageBO.setClerkId(relationDTO.getClerkId() != null ? relationDTO.getClerkId() : "-1");
noticeMessageBO.setStoreId(relationDTO.getStoreId() != null ? relationDTO.getStoreId() : "-1");
noticeMessageBO.setTitle(StringUtils.isNotBlank(notifyMessageBatchQDTO.getTitle())? notifyMessageBatchQDTO.getTitle(): messageTypeEnum.getName());
noticeMessageBO.setTemplateCode(messageTypeEnum.getTemplateCode());
noticeMessageBO.setDescription(haobanNotice);
noticeMessageBO.setEnterpriseId(notifyMessageBatchQDTO.getEnterpriseId());
noticeMessageBO.setRelationId(notifyMessageBatchQDTO.getOptTargetId());
noticeMessageBO.setMessageContent(notifyMessageBatchQDTO.getExtendContent() != null ? JSONObject.toJSONString(notifyMessageBatchQDTO.getExtendContent()) : null);
noticeMessageBOList.add(noticeMessageBO);
}
noticeMessageService.addNoticeMessageBatch(noticeMessageBOList);
QywxXcxSendMessageDTO messageDTO = new QywxXcxSendMessageDTO();
String data = notifyMessageBatchQDTO.getExtendContent() != null ? JSONObject.toJSONString(notifyMessageBatchQDTO.getExtendContent()) : null;
String title = StringUtils.isNotBlank(notifyMessageBatchQDTO.getTitle()) ? notifyMessageBatchQDTO.getTitle() : messageTypeEnum.getName();
List<ItemDTO> items = contentList.stream().map(bo -> {
ItemDTO item = new ItemDTO();
item.setKey(bo.getKey());
item.setValue(bo.getVal());
return item;
}).collect(Collectors.toList());
if (StringUtils.isNotBlank(data)) {
try {
data = URLEncoder.encode(data, StandardCharsets.UTF_8.name());
} catch (UnsupportedEncodingException e) {
logger.error(e.getMessage());
}
}
String appUrl = messageTypeEnum.getPageUrl();
if (StringUtils.isNotBlank(messageTypeEnum.getPageType())) {
appUrl += messageTypeEnum.getPageType();
}
appUrl += "&data=" + data;
messageDTO.setAppid(config.getAppid());
messageDTO.setUserIds(wxUserIdList);
messageDTO.setPage(appUrl);
messageDTO.setTitle(StringUtils.isNotBlank(title)?title: messageTypeEnum.getName());
messageDTO.setItems(items);
boolean sendMessage = qywxSuiteApiService.sendMessage(qwDTO.getThirdCorpid(), config.getWxSuiteid(), messageDTO);
NotifyMessageMQDTO mqdto = new NotifyMessageMQDTO();
List<String> clerkIdList = list.stream().map(StaffClerkRelationDTO::getClerkId).collect(Collectors.toList());
mqdto.setClerkIdList(clerkIdList);
mqdto.setTemplateCode(messageTypeEnum.getTemplateCode());
mqdto.setExtendContent(notifyMessageBatchQDTO.getExtendContent());
mqdto.setResult(sendMessage?Constant.FLAG_TRUE:Constant.FLAG_FALSE);
try {
GICMQClientUtil.getClientInstance().sendMessage("haobanNotifyEvent",JSON.toJSONString(mqdto));
} catch (Exception e) {
logger.info(e.getMessage(), e);
}
}
@Override
public ServiceResponse<Page<NoticeMessageInfoDTO>> pageNoticeMessage(String enterpriseId, String storeId, String clerkId, int categoryType, BasePageInfo pageInfo) { public ServiceResponse<Page<NoticeMessageInfoDTO>> pageNoticeMessage(String enterpriseId, String storeId, String clerkId, int categoryType, BasePageInfo pageInfo) {
if (StringUtils.isAnyBlank(enterpriseId, storeId)) { if (StringUtils.isAnyBlank(enterpriseId, storeId)) {
return ServiceResponse.failure(HaoBanErrCode.ERR_0001.getCode(), HaoBanErrCode.ERR_0001.getMsg()); return ServiceResponse.failure(HaoBanErrCode.ERR_0001.getCode(), HaoBanErrCode.ERR_0001.getMsg());
...@@ -230,7 +377,7 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService { ...@@ -230,7 +377,7 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
* @param wxUserId * @param wxUserId
* @param messageTypeEnum * @param messageTypeEnum
*/ */
private void sendMessage(List<TemplateContentBO> contentList, String wxEnterpriseId, String staffId, NoticeMessageTypeEnum messageTypeEnum, String data) { private void sendMessage(List<TemplateContentBO> contentList, String wxEnterpriseId, String staffId, NoticeMessageTypeEnum messageTypeEnum, String data,String title) {
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ; WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
QywxXcxSendMessageDTO messageDTO = new QywxXcxSendMessageDTO(); QywxXcxSendMessageDTO messageDTO = new QywxXcxSendMessageDTO();
String corpid = qwDTO.getThirdCorpid() ; String corpid = qwDTO.getThirdCorpid() ;
...@@ -267,7 +414,7 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService { ...@@ -267,7 +414,7 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
messageDTO.setAppid(config.getAppid()); messageDTO.setAppid(config.getAppid());
messageDTO.setUserIds(userList); messageDTO.setUserIds(userList);
messageDTO.setPage(appUrl); messageDTO.setPage(appUrl);
messageDTO.setTitle(messageTypeEnum.getName()); messageDTO.setTitle(StringUtils.isNotBlank(title)?title:messageTypeEnum.getName());
messageDTO.setItems(items); messageDTO.setItems(items);
qywxSuiteApiService.sendMessage(corpid, config.getWxSuiteid(), messageDTO); qywxSuiteApiService.sendMessage(corpid, config.getWxSuiteid(), messageDTO);
} }
......
...@@ -47,6 +47,21 @@ ...@@ -47,6 +47,21 @@
#{deleteFlag,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP} #{deleteFlag,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
) )
</insert> </insert>
<insert id="insertBatch">
insert into tab_haoban_notice_message (notice_message_id, enterprise_id, store_id,
clerk_id, category_type, message_type,
template_code, title, description,
relation_id, message_content, create_time, update_time
)
values
<foreach collection="records" item="record" separator=",">
(#{record.noticeMessageId,jdbcType=BIGINT}, #{record.enterpriseId,jdbcType=VARCHAR}, #{record.storeId,jdbcType=VARCHAR},
#{record.clerkId,jdbcType=VARCHAR}, #{record.categoryType,jdbcType=INTEGER}, #{record.messageType,jdbcType=INTEGER},
#{record.templateCode,jdbcType=VARCHAR}, #{record.title,jdbcType=VARCHAR}, #{record.description,jdbcType=VARCHAR},
#{record.relationId,jdbcType=VARCHAR}, #{record.messageContent,jdbcType=VARCHAR}, #{record.createTime,jdbcType=TIMESTAMP}, #{record.updateTime,jdbcType=TIMESTAMP}
)
</foreach>
</insert>
<insert id="insertSelective" parameterType="com.gic.haoban.manage.service.entity.TabNoticeMessage"> <insert id="insertSelective" parameterType="com.gic.haoban.manage.service.entity.TabNoticeMessage">
insert into tab_haoban_notice_message insert into tab_haoban_notice_message
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
......
...@@ -7,7 +7,6 @@ import com.gic.haoban.manage.api.service.MemberUnionidRelatedApiService; ...@@ -7,7 +7,6 @@ import com.gic.haoban.manage.api.service.MemberUnionidRelatedApiService;
import com.gic.haoban.manage.api.service.StaffApiService; import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.StaffClerkRelationApiService; import com.gic.haoban.manage.api.service.StaffClerkRelationApiService;
import com.gic.haoban.manage.service.service.StaffService; import com.gic.haoban.manage.service.service.StaffService;
import com.gic.haoban.manage.service.service.TestService;
import com.gic.wechat.api.dto.qywx.DepartmentDTO; import com.gic.wechat.api.dto.qywx.DepartmentDTO;
import com.gic.wechat.api.service.qywx.QywxDepartmentApiService; import com.gic.wechat.api.service.qywx.QywxDepartmentApiService;
import com.gic.wechat.api.service.qywx.QywxUserApiService; import com.gic.wechat.api.service.qywx.QywxUserApiService;
...@@ -44,9 +43,6 @@ public class DealSyncTest { ...@@ -44,9 +43,6 @@ public class DealSyncTest {
private QywxDepartmentApiService qywxDepartmentApiService; private QywxDepartmentApiService qywxDepartmentApiService;
@Autowired @Autowired
private TestService testService;
@Autowired
private StaffClerkRelationApiService staffClerkRelationApiService; private StaffClerkRelationApiService staffClerkRelationApiService;
@Autowired @Autowired
......
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.gic.haoban.manage.api.dto.AlertMessageDTO; import com.gic.haoban.manage.api.dto.AlertMessageDTO;
import com.gic.haoban.manage.api.dto.notify.qdto.NoticeMessageQDTO; import com.gic.haoban.manage.api.dto.notify.qdto.NoticeMessageQDTO;
import com.gic.haoban.manage.api.dto.notify.qdto.NotifyMessageBatchQDTO;
import com.gic.haoban.manage.api.enums.AlertTypeEnum; import com.gic.haoban.manage.api.enums.AlertTypeEnum;
import com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum; import com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum;
import com.gic.haoban.manage.api.service.CheckQywxSettingApiService; import com.gic.haoban.manage.api.service.CheckQywxSettingApiService;
import com.gic.haoban.manage.api.service.QywxTagApiService; import com.gic.haoban.manage.api.service.QywxTagApiService;
import com.gic.haoban.manage.api.service.notify.NoticeMessageApiService; import com.gic.haoban.manage.api.service.notify.NoticeMessageApiService;
import com.google.common.collect.Lists;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -62,4 +64,22 @@ public class NotityTest { ...@@ -62,4 +64,22 @@ public class NotityTest {
qywxTagApiService.checkQywxSync("-1"); qywxTagApiService.checkQywxSync("-1");
} }
@Test
public void batchSendMessage() {
NotifyMessageBatchQDTO qdto = new NotifyMessageBatchQDTO();
qdto.setStoreIdList(Lists.newArrayList("ff8080817c2b4c55017c30a4482800d7"));
qdto.setOptTargetId("-1");
Map<String, Object> map1 = new HashMap<>();
map1.put("materialNotifyId", 111);
qdto.setExtendContent(map1);
qdto.setEnterpriseId("ff8080815dacd3a2015dacd3ef5c0000");
qdto.setMessageType(NoticeMessageTypeEnum.MATERIAL_NEW_NOTIFY.getType());
qdto.setTemplateCode(NoticeMessageTypeEnum.MATERIAL_NEW_NOTIFY.getTemplateCode());
qdto.setTitle("素材上新通知");
Map<String, String> map = new HashMap<>();
map.put("content", "有新的素材了,快来看啊!");
qdto.setContentMap(map);
noticeMessageApiService.batchSendMessage(qdto);
}
} }
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