Commit 816f6f0f by fudahua

消息通知接口以及发送通知接口

parent a5b1f236
package com.gic.haoban.manage.api.dto.notify.dto;
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 NoticeMessageInfoDTO 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 title;
/**
* 描述
*/
private String description;
/**
* 消息带的参数信息
*/
private String messageContent;
/**
* 0 未读 1已读
*/
private Integer readFlag;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
/**
*/
private static final long serialVersionUID = 1L;
public Long getNoticeMessageId() {
return noticeMessageId;
}
public void setNoticeMessageId(Long noticeMessageId) {
this.noticeMessageId = noticeMessageId;
}
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public String getStoreId() {
return storeId;
}
public void setStoreId(String storeId) {
this.storeId = storeId;
}
public String getClerkId() {
return clerkId;
}
public void setClerkId(String clerkId) {
this.clerkId = clerkId;
}
public Integer getCategoryType() {
return categoryType;
}
public void setCategoryType(Integer categoryType) {
this.categoryType = categoryType;
}
public Integer getMessageType() {
return messageType;
}
public void setMessageType(Integer messageType) {
this.messageType = messageType;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getMessageContent() {
return messageContent;
}
public void setMessageContent(String messageContent) {
this.messageContent = messageContent;
}
public Integer getReadFlag() {
return readFlag;
}
public void setReadFlag(Integer readFlag) {
this.readFlag = readFlag;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
\ No newline at end of file
...@@ -4,13 +4,14 @@ package com.gic.haoban.manage.api.enums; ...@@ -4,13 +4,14 @@ package com.gic.haoban.manage.api.enums;
* Created by hua on 2021/12/17. * Created by hua on 2021/12/17.
*/ */
public enum NoticeMessageTypeEnum { public enum NoticeMessageTypeEnum {
ACTIVITY_START(1001, "活动开始通知", NoticeMessageCategoryTypeEnum.ACTIVITY.getType(), "activity_message", ""),
ACTIVITY_NEW(1002, "活动上新通知", NoticeMessageCategoryTypeEnum.ACTIVITY.getType(), "activity_message", ""), ACTIVITY_START(1001, "活动开始通知", NoticeMessageCategoryTypeEnum.ACTIVITY.getType(), "activity_message", "/pages/route/index"),
ACTIVITY_DEL(1003, "活动删除通知", NoticeMessageCategoryTypeEnum.ACTIVITY.getType(), "activity_message", ""), ACTIVITY_NEW(1002, "活动上新通知", NoticeMessageCategoryTypeEnum.ACTIVITY.getType(), "activity_message", "/pages/route/index"),
ACTIVITY_OFFLINE(1004, "活动下线通知", NoticeMessageCategoryTypeEnum.ACTIVITY.getType(), "activity_message", ""), ACTIVITY_DEL(1003, "活动删除通知", NoticeMessageCategoryTypeEnum.ACTIVITY.getType(), "activity_message", "/pages/route/index"),
ACTIVITY_END(1005, "活动结束通知", NoticeMessageCategoryTypeEnum.ACTIVITY.getType(), "activity_message", ""), ACTIVITY_OFFLINE(1004, "活动下线通知", NoticeMessageCategoryTypeEnum.ACTIVITY.getType(), "activity_message", "/pages/route/index"),
ACTIVITY_RANK(1006, "活动排名通知", NoticeMessageCategoryTypeEnum.ACTIVITY.getType(), "activity_message", ""), ACTIVITY_END(1005, "活动结束通知", NoticeMessageCategoryTypeEnum.ACTIVITY.getType(), "activity_message", "/pages/route/index"),
ACTIVITY_AWARD(1007, "活动奖励通知", NoticeMessageCategoryTypeEnum.ACTIVITY.getType(), "activity_message", ""); ACTIVITY_RANK(1006, "活动排名通知", NoticeMessageCategoryTypeEnum.ACTIVITY.getType(), "activity_message", "/pages/route/index"),
ACTIVITY_AWARD(1007, "活动奖励通知", NoticeMessageCategoryTypeEnum.ACTIVITY.getType(), "activity_message", "/pages/route/index");
/** /**
* 消息类型 * 消息类型
*/ */
......
package com.gic.haoban.manage.api.service.notify; package com.gic.haoban.manage.api.service.notify;
import com.gic.api.base.commons.BasePageInfo;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.haoban.manage.api.dto.notify.dto.NoticeMessageInfoDTO;
/** /**
* Created 2021/12/17. * Created 2021/12/17.
* *
* @author hua * @author hua
*/ */
public interface NoticeMessageApiService { public interface NoticeMessageApiService {
/**
* 消息接收 发送消息
*
* @param json
*/
public void noticeMessageMq(String json); public void noticeMessageMq(String json);
/**
* 消息分页
*
* @param enterpriseId
* @param storeId
* @param clerkId 可以空 标识查询门店级别消息
* @param categoryType
* @param pageInfo
* @return
*/
public ServiceResponse<Page<NoticeMessageInfoDTO>> pageNoticeMessage(String enterpriseId, String storeId, String clerkId, int categoryType, BasePageInfo pageInfo);
/**
* 更新已读状态
*
* @param id
* @return
*/
public ServiceResponse<Boolean> updateReadFlagById(Long id);
/**
* 更新某人的所有已读状态
*
* @param enterpriseId
* @param clerkId
* @param categoryType
* @return
*/
public ServiceResponse<Boolean> updateWriteFlagByClerkId(String enterpriseId, String clerkId, int categoryType);
} }
\ No newline at end of file
...@@ -29,10 +29,11 @@ public class NoticeMessageUtil { ...@@ -29,10 +29,11 @@ public class NoticeMessageUtil {
* @param enterpriseId 企业id * @param enterpriseId 企业id
* @param clerkId 执行人导购 * @param clerkId 执行人导购
* @param messageType 消息类型 NoticeMessageTypeEnum * @param messageType 消息类型 NoticeMessageTypeEnum
* @param optTargetId 操作对象
* @param fieldMap 解析模板的字段 * @param fieldMap 解析模板的字段
* @param extendField 拓展字段给前端使用 没有可以为null * @param extendField 拓展字段给前端使用 没有可以为null
*/ */
public static void sendNoticeMessage(String enterpriseId, String clerkId, int messageType, Map<String, String> fieldMap, Map<String, Object> extendField) { public static void sendNoticeMessage(String enterpriseId, String clerkId, int messageType, String optTargetId, Map<String, String> fieldMap, Map<String, Object> extendField) {
if (StringUtils.isAnyBlank(enterpriseId, clerkId)) { if (StringUtils.isAnyBlank(enterpriseId, clerkId)) {
throw new RuntimeException("必传参数没传"); throw new RuntimeException("必传参数没传");
} }
...@@ -46,6 +47,7 @@ public class NoticeMessageUtil { ...@@ -46,6 +47,7 @@ public class NoticeMessageUtil {
noticeMessageQDTO.setMessageType(messageType); noticeMessageQDTO.setMessageType(messageType);
noticeMessageQDTO.setContentMap(fieldMap); noticeMessageQDTO.setContentMap(fieldMap);
noticeMessageQDTO.setExtendContent(extendField); noticeMessageQDTO.setExtendContent(extendField);
noticeMessageQDTO.setOptTargetId(optTargetId);
String ret = JSONObject.toJSONString(noticeMessageQDTO); String ret = JSONObject.toJSONString(noticeMessageQDTO);
logger.info("发送消息:{}", ret); logger.info("发送消息:{}", ret);
GicMQClient clientInstance = GICMQClientUtil.getClientInstance(); GicMQClient clientInstance = GICMQClientUtil.getClientInstance();
......
...@@ -2,6 +2,9 @@ package com.gic.haoban.manage.service.dao.mapper; ...@@ -2,6 +2,9 @@ package com.gic.haoban.manage.service.dao.mapper;
import com.gic.haoban.manage.service.entity.TabNoticeMessage; import com.gic.haoban.manage.service.entity.TabNoticeMessage;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper @Mapper
public interface NoticeMessageMapper { public interface NoticeMessageMapper {
...@@ -28,4 +31,26 @@ public interface NoticeMessageMapper { ...@@ -28,4 +31,26 @@ public interface NoticeMessageMapper {
/** /**
*/ */
int updateByPrimaryKey(TabNoticeMessage record); int updateByPrimaryKey(TabNoticeMessage record);
/**
* 查询列表 根据导购
*
* @param enterpriseId
* @param storeId
* @param clerkId
* @param categoryType
* @return
*/
List<TabNoticeMessage> listNoticeMessage(@Param("enterpriseId") String enterpriseId,
@Param("storeId") String storeId,
@Param("clerkId") String clerkId,
@Param("categoryType") int categoryType);
/**
*/
int updateNoticeMessageReadFlag(@Param("enterpriseId") String enterpriseId,
@Param("clerkId") String clerkId,
@Param("categoryType") int categoryType);
} }
\ No newline at end of file
...@@ -7,7 +7,6 @@ import java.util.Date; ...@@ -7,7 +7,6 @@ import java.util.Date;
* Created By MBG-GUI-EXTENSION https://github.com/spawpaw/mybatis-generator-gui-extension * Created By MBG-GUI-EXTENSION https://github.com/spawpaw/mybatis-generator-gui-extension
* Description: * Description:
* 好办消息通知 * 好办消息通知
*
* @author fdh * @author fdh
*/ */
public class TabNoticeMessage implements Serializable { public class TabNoticeMessage implements Serializable {
...@@ -17,67 +16,85 @@ public class TabNoticeMessage implements Serializable { ...@@ -17,67 +16,85 @@ public class TabNoticeMessage implements Serializable {
private Long noticeMessageId; private Long noticeMessageId;
/** /**
* 企业id * 企业id
*
*/ */
private String enterpriseId; private String enterpriseId;
/** /**
* 门店id * 门店id
*
*/ */
private String storeId; private String storeId;
/** /**
* 导购id * 导购id
*
*/ */
private String clerkId; private String clerkId;
/** /**
* 类别 0客户相关、1任务相关、2活动相关、3其他 * 类别 0客户相关、1任务相关、2活动相关、3其他
*
*/ */
private Integer categoryType; private Integer categoryType;
/** /**
* 消息类型 * 消息类型
*
*/ */
private Integer messageType; private Integer messageType;
/** /**
* 标题 * 模板编号
*/
private String templateCode;
/**
* 标题
*
*/ */
private String title; private String title;
/** /**
* 描述 * 描述
*
*/ */
private String description; private String description;
/** /**
* 关联的具体业务消息id * 关联的具体业务消息id
*
*/ */
private String relationId; private String relationId;
/** /**
* 消息带的参数信息 * 消息带的参数信息
*
*/ */
private String messageContent; private String messageContent;
/** /**
* 0 未读 1已读 * 0 未读 1已读
*
*/ */
private Integer readFlag; private Integer readFlag;
/** /**
* 状态 0删除 1正常 * 状态 0删除 1正常
*
*/ */
private Integer deleteFlag; private Integer deleteFlag;
/** /**
* 创建时间 * 创建时间
*
*/ */
private Date createTime; private Date createTime;
/** /**
* 更新时间 * 更新时间
*
*/ */
private Date updateTime; private Date updateTime;
...@@ -194,6 +211,24 @@ public class TabNoticeMessage implements Serializable { ...@@ -194,6 +211,24 @@ public class TabNoticeMessage implements Serializable {
} }
/** /**
* This method returns the value of the database column tab_haoban_notice_message.template_code
*
* @return the value of tab_haoban_notice_message.template_code
*/
public String getTemplateCode() {
return templateCode;
}
/**
* This method sets the value of the database column tab_haoban_notice_message.template_code
*
* @param templateCode the value for tab_haoban_notice_message.template_code
*/
public void setTemplateCode(String templateCode) {
this.templateCode = templateCode;
}
/**
* This method returns the value of the database column tab_haoban_notice_message.title * This method returns the value of the database column tab_haoban_notice_message.title
* *
* @return the value of tab_haoban_notice_message.title * @return the value of tab_haoban_notice_message.title
......
package com.gic.haoban.manage.service.errorcode;
/**
* Created by fudh on 2018/3/4.
*/
public enum HaoBanErrCode {
ERR_0001("10100001", "参数没有传"),;
private String code;
private String msg;
HaoBanErrCode(String code, String msg) {
this.code = code;
this.msg = msg;
}
public static HaoBanErrCode getValue(String code) {
for (HaoBanErrCode sec : HaoBanErrCode.values()) {
if (code == sec.getCode()) {
return sec;
}
}
return null;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
...@@ -41,6 +41,8 @@ public class NoticeMessageBO implements Serializable { ...@@ -41,6 +41,8 @@ public class NoticeMessageBO implements Serializable {
*/ */
private Integer messageType; private Integer messageType;
private String templateCode;
/** /**
* 标题 * 标题
*/ */
...@@ -85,6 +87,14 @@ public class NoticeMessageBO implements Serializable { ...@@ -85,6 +87,14 @@ public class NoticeMessageBO implements Serializable {
*/ */
private static final long serialVersionUID = 1L; 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 * This method returns the value of the database column tab_haoban_notice_message.notice_message_id
* *
......
package com.gic.haoban.manage.service.service.notify; package com.gic.haoban.manage.service.service.notify;
import com.gic.api.base.commons.BasePageInfo;
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;
...@@ -18,5 +20,27 @@ public interface NoticeMessageService { ...@@ -18,5 +20,27 @@ public interface NoticeMessageService {
*/ */
public boolean addOrCreateNoticeMessage(NoticeMessageBO messageBO); public boolean addOrCreateNoticeMessage(NoticeMessageBO messageBO);
/**
* 分页查询消息
*
* @param enterpriseId
* @param storeId 门店id
* @param clerkId
* @param categoryType
* @param pageInfo
* @return
*/
public Page<NoticeMessageBO> pageNoticeMessage(String enterpriseId, String storeId, String clerkId, int categoryType, BasePageInfo pageInfo);
/**
* 更新导购的已读转态
*
* @param enterpriseId
* @param clerkId
* @param categoryType
* @return
*/
public boolean updateNoticeMessageReadFlag(String enterpriseId, String clerkId, int categoryType);
} }
package com.gic.haoban.manage.service.service.notify.impl; package com.gic.haoban.manage.service.service.notify.impl;
import com.gic.api.base.commons.BasePageInfo;
import com.gic.api.base.commons.Page;
import com.gic.commons.util.PageHelperUtils;
import com.gic.commons.util.UniqueIdUtils; import com.gic.commons.util.UniqueIdUtils;
import com.gic.haoban.common.utils.EntityUtil; import com.gic.haoban.common.utils.EntityUtil;
import com.gic.haoban.manage.service.dao.mapper.NoticeMessageMapper; import com.gic.haoban.manage.service.dao.mapper.NoticeMessageMapper;
...@@ -7,10 +10,12 @@ import com.gic.haoban.manage.service.entity.TabNoticeMessage; ...@@ -7,10 +10,12 @@ import com.gic.haoban.manage.service.entity.TabNoticeMessage;
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 com.gic.haoban.manage.service.service.notify.NoticeMessageService; import com.gic.haoban.manage.service.service.notify.NoticeMessageService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* Created 2021/12/17. * Created 2021/12/17.
...@@ -36,4 +41,18 @@ public class NoticeMessageServiceImpl implements NoticeMessageService { ...@@ -36,4 +41,18 @@ public class NoticeMessageServiceImpl implements NoticeMessageService {
noticeMessageMapper.updateByPrimaryKeySelective(tabNoticeMessage); noticeMessageMapper.updateByPrimaryKeySelective(tabNoticeMessage);
return true; return true;
} }
@Override
public Page<NoticeMessageBO> pageNoticeMessage(String enterpriseId, String storeId, String clerkId, int categoryType, BasePageInfo pageInfo) {
PageHelper.startPage(pageInfo);
List<TabNoticeMessage> list = noticeMessageMapper.listNoticeMessage(enterpriseId, storeId, clerkId, categoryType);
Page<NoticeMessageBO> retPage = PageHelperUtils.changePageHelperToCurrentPage(list, NoticeMessageBO.class);
return retPage;
}
@Override
public boolean updateNoticeMessageReadFlag(String enterpriseId, String clerkId, int categoryType) {
noticeMessageMapper.updateNoticeMessageReadFlag(enterpriseId, clerkId, categoryType);
return true;
}
} }
package com.gic.haoban.manage.service.service.notify.out; package com.gic.haoban.manage.service.service.notify.out;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.BasePageInfo;
import com.gic.api.base.commons.Constant;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.clerk.api.service.ClerkService; import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.PageHelperUtils;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO; import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO; import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.dto.notify.dto.NoticeMessageInfoDTO;
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.enums.NoticeMessageTypeEnum; import com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum;
import com.gic.haoban.manage.api.service.notify.NoticeMessageApiService; import com.gic.haoban.manage.api.service.notify.NoticeMessageApiService;
import com.gic.haoban.manage.service.config.Config; import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.errorcode.HaoBanErrCode;
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.TemplateContentBO; import com.gic.haoban.manage.service.pojo.bo.TemplateContentBO;
import com.gic.haoban.manage.service.service.StaffClerkRelationService; import com.gic.haoban.manage.service.service.StaffClerkRelationService;
...@@ -77,7 +84,7 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService { ...@@ -77,7 +84,7 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
logger.info("没有模板,无法发送消息:{}", messageQDTO.getTemplateCode()); logger.info("没有模板,无法发送消息:{}", messageQDTO.getTemplateCode());
return; return;
} }
StaffClerkRelationDTO clerkRelationDTO = staffClerkRelationService.getBindByClerkId(messageQDTO.getClerkId(), messageQDTO.getEnterpriseId()); StaffClerkRelationDTO clerkRelationDTO = staffClerkRelationService.getByClerkId(messageQDTO.getClerkId());
if (clerkRelationDTO == null) { if (clerkRelationDTO == null) {
logger.info("没有导购:{}", messageQDTO.getClerkId()); logger.info("没有导购:{}", messageQDTO.getClerkId());
return; return;
...@@ -89,15 +96,43 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService { ...@@ -89,15 +96,43 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
noticeMessageBO.setClerkId(messageQDTO.getClerkId()); noticeMessageBO.setClerkId(messageQDTO.getClerkId());
noticeMessageBO.setStoreId(clerkRelationDTO.getStoreId()); noticeMessageBO.setStoreId(clerkRelationDTO.getStoreId());
noticeMessageBO.setTitle(messageTypeEnum.getName()); noticeMessageBO.setTitle(messageTypeEnum.getName());
noticeMessageBO.setTemplateCode(messageTypeEnum.getTemplateCode());
noticeMessageBO.setDescription(haobanNotice); noticeMessageBO.setDescription(haobanNotice);
noticeMessageBO.setEnterpriseId(messageQDTO.getEnterpriseId()); noticeMessageBO.setEnterpriseId(messageQDTO.getEnterpriseId());
noticeMessageBO.setRelationId(messageQDTO.getOptTargetId()); noticeMessageBO.setRelationId(messageQDTO.getOptTargetId());
noticeMessageBO.setMessageContent(messageQDTO.getExtendContent() != null ? JSONObject.toJSONString(messageQDTO.getExtendContent()) : null);
noticeMessageService.addOrCreateNoticeMessage(noticeMessageBO); noticeMessageService.addOrCreateNoticeMessage(noticeMessageBO);
//发送企业微信 //发送企业微信
sendMessage(contentList, clerkRelationDTO.getWxEnterpriseId(), clerkRelationDTO.getWxUserId(), messageTypeEnum); sendMessage(contentList, clerkRelationDTO.getWxEnterpriseId(), clerkRelationDTO.getWxUserId(), messageTypeEnum);
} }
@Override
public ServiceResponse<Page<NoticeMessageInfoDTO>> pageNoticeMessage(String enterpriseId, String storeId, String clerkId, int categoryType, BasePageInfo pageInfo) {
if (StringUtils.isAnyBlank(enterpriseId, storeId)) {
ServiceResponse.failure(HaoBanErrCode.ERR_0001.getCode(), HaoBanErrCode.ERR_0001.getMsg());
}
Page<NoticeMessageBO> retPage = noticeMessageService.pageNoticeMessage(enterpriseId, storeId, clerkId, categoryType, pageInfo);
Page<NoticeMessageInfoDTO> tPage = PageHelperUtils.changePageToCurrentPage(retPage, NoticeMessageInfoDTO.class);
return ServiceResponse.success(tPage);
}
@Override
public ServiceResponse<Boolean> updateReadFlagById(Long id) {
NoticeMessageBO noticeMessageBO = new NoticeMessageBO();
noticeMessageBO.setNoticeMessageId(id);
noticeMessageBO.setReadFlag(Constant.NUMBER_1);
noticeMessageService.addOrCreateNoticeMessage(noticeMessageBO);
return ServiceResponse.success(true);
}
@Override
public ServiceResponse<Boolean> updateWriteFlagByClerkId(String enterpriseId, String clerkId, int categoryType) {
noticeMessageService.updateNoticeMessageReadFlag(enterpriseId, clerkId, categoryType);
return ServiceResponse.success(true);
}
/** /**
* 获取详情 * 获取详情
* *
...@@ -116,12 +151,13 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService { ...@@ -116,12 +151,13 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
//替换的内容 //替换的内容
for (TemplateContentBO templateContentBO : templateMessage) { for (TemplateContentBO templateContentBO : templateMessage) {
contentMap.forEach((k, v) -> { contentMap.forEach((k, v) -> {
templateContentBO.getVal().replaceAll("#{" + k + "}", v); templateContentBO.setVal(templateContentBO.getVal().replaceAll("\\#\\{" + k + "\\}", v));
}); });
} }
return templateMessage; return templateMessage;
} }
/** /**
* 获取详情好办的通知 * 获取详情好办的通知
* *
...@@ -129,8 +165,8 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService { ...@@ -129,8 +165,8 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
* @return * @return
*/ */
private String getHaobanNotice(NoticeMessageQDTO messageQDTO) { private String getHaobanNotice(NoticeMessageQDTO messageQDTO) {
String haobanTemplateMessage = noticeMessageTemplateService.getHaobanTemplateMessage(messageQDTO.getEnterpriseId(), messageQDTO.getTemplateCode()); final String[] haobanTemplateMessage = {noticeMessageTemplateService.getHaobanTemplateMessage(messageQDTO.getEnterpriseId(), messageQDTO.getTemplateCode())};
if (StringUtils.isBlank(haobanTemplateMessage)) { if (StringUtils.isBlank(haobanTemplateMessage[0])) {
//todo 需要告警 //todo 需要告警
logger.info("不存在好办的通知模板模板"); logger.info("不存在好办的通知模板模板");
return null; return null;
...@@ -139,9 +175,9 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService { ...@@ -139,9 +175,9 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
Map<String, String> contentMap = messageQDTO.getContentMap(); Map<String, String> contentMap = messageQDTO.getContentMap();
//替换的内容 //替换的内容
contentMap.forEach((k, v) -> { contentMap.forEach((k, v) -> {
haobanTemplateMessage.replaceAll("#{" + k + "}", v); haobanTemplateMessage[0] = haobanTemplateMessage[0].replaceAll("\\#\\{" + k + "\\}", v);
}); });
return haobanTemplateMessage; return haobanTemplateMessage[0];
} }
/** /**
......
...@@ -33,4 +33,5 @@ public class CommonUtil { ...@@ -33,4 +33,5 @@ public class CommonUtil {
} }
return null; return null;
} }
} }
...@@ -63,6 +63,10 @@ ...@@ -63,6 +63,10 @@
ref="pendingTaskApiServiceImpl" ref="pendingTaskApiServiceImpl"
timeout="10000"/> timeout="10000"/>
<dubbo:service interface="com.gic.haoban.manage.api.service.notify.NoticeMessageApiService"
ref="noticeMessageApiServiceImpl"
timeout="10000"/>
<dubbo:reference interface="com.gic.enterprise.api.service.DepartmentService" id="gicDepartmentService"/> <dubbo:reference interface="com.gic.enterprise.api.service.DepartmentService" id="gicDepartmentService"/>
<dubbo:reference interface="com.gic.wechat.api.service.qywx.QywxDepartmentApiService" id="qywxDepartmentApiService"/> <dubbo:reference interface="com.gic.wechat.api.service.qywx.QywxDepartmentApiService" id="qywxDepartmentApiService"/>
<dubbo:reference interface="com.gic.wechat.api.service.qywx.QywxSuiteApiService" id="qywxSuiteApiService"/> <dubbo:reference interface="com.gic.wechat.api.service.qywx.QywxSuiteApiService" id="qywxSuiteApiService"/>
......
...@@ -118,10 +118,10 @@ ...@@ -118,10 +118,10 @@
where notice_message_template_id = #{noticeMessageTemplateId,jdbcType=INTEGER} where notice_message_template_id = #{noticeMessageTemplateId,jdbcType=INTEGER}
</update> </update>
<select id="getByCode" parameterType="java.lang.Integer" resultMap="BaseResultMap"> <select id="getByCode" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from tab_haoban_notice_message_template from tab_haoban_notice_message_template
where template_code = #{templateCode} and enterprise_id=#{enterpriseId} and delete_flag=0 where template_code = #{templateCode,jdbcType=VARCHAR} and enterprise_id=#{enterpriseId} and delete_flag=0
</select> </select>
</mapper> </mapper>
\ No newline at end of file
import com.alibaba.fastjson.JSONObject;
import com.gic.haoban.manage.api.dto.AlertMessageDTO;
import com.gic.haoban.manage.api.dto.notify.qdto.NoticeMessageQDTO;
import com.gic.haoban.manage.api.enums.AlertTypeEnum;
import com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum;
import com.gic.haoban.manage.api.service.CheckQywxSettingApiService;
import com.gic.haoban.manage.api.service.QywxTagApiService;
import com.gic.haoban.manage.api.service.notify.NoticeMessageApiService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.HashMap;
import java.util.Map;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext-conf.xml"})
public class NotityTest {
private static Logger logger = LoggerFactory.getLogger(NotityTest.class);
@Autowired
private QywxTagApiService qywxTagApiService;
@Autowired
private NoticeMessageApiService noticeMessageApiService;
@Test
public void test() {
Map<String, String> contentMap = new HashMap<String, String>();
contentMap.put("test", "test");
Map<String, Object> extMap = new HashMap<String, Object>();
extMap.put("test111", "tes111t");
NoticeMessageQDTO noticeMessageQDTO = new NoticeMessageQDTO();
noticeMessageQDTO.setEnterpriseId("ff8080815dacd3a2015dacd3ef5c0000");
noticeMessageQDTO.setMessageType(NoticeMessageTypeEnum.ACTIVITY_AWARD.getType());
noticeMessageQDTO.setContentMap(contentMap);
noticeMessageQDTO.setClerkId("70eb25bfb94b4ffb998d4bd817fbd7e2");
noticeMessageQDTO.setOptTargetId("testtatget");
noticeMessageQDTO.setExtendContent(extMap);
noticeMessageApiService.noticeMessageMq(JSONObject.toJSONString(noticeMessageQDTO));
}
@Test
public void test2() {
}
@Test
public void test3() {
qywxTagApiService.checkQywxSync("-1");
}
}
...@@ -17,12 +17,10 @@ import org.apache.commons.lang3.time.DateUtils; ...@@ -17,12 +17,10 @@ import org.apache.commons.lang3.time.DateUtils;
public class test { public class test {
public static void main(String[] args) { public static void main(String[] args) {
String content = "请完善完善202005门店指标月份指"; String content = "测试模板#{test}";
String pattern = ".*([0-1]{6}).*"; String test = "1test";
Pattern r = Pattern.compile(pattern); String replace = content.replaceAll("\\#\\{" + test + "\\}", "1111");
Matcher matcher = r.matcher(content); System.out.println(replace);
String s = matcher.find() ? matcher.group(1) : "";
System.out.println(s);
// String key = "3.2.1"; // String key = "3.2.1";
......
...@@ -27,6 +27,7 @@ import com.gic.haoban.manage.api.dto.*; ...@@ -27,6 +27,7 @@ import com.gic.haoban.manage.api.dto.*;
import com.gic.haoban.manage.api.enums.*; import com.gic.haoban.manage.api.enums.*;
import com.gic.haoban.manage.api.service.*; import com.gic.haoban.manage.api.service.*;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode; import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.qo.CommonQO;
import com.gic.haoban.manage.web.vo.*; import com.gic.haoban.manage.web.vo.*;
import com.gic.redis.data.util.RedisUtil; import com.gic.redis.data.util.RedisUtil;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
...@@ -34,10 +35,12 @@ import org.apache.commons.lang3.StringUtils; ...@@ -34,10 +35,12 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -1126,4 +1129,16 @@ public class ClerkController extends WebBaseController { ...@@ -1126,4 +1129,16 @@ public class ClerkController extends WebBaseController {
externalClerkRelatedApiService.pushExternalByRelationKey(relationKey); externalClerkRelatedApiService.pushExternalByRelationKey(relationKey);
return resultResponse(HaoBanErrCode.ERR_1); return resultResponse(HaoBanErrCode.ERR_1);
} }
/**
* 我的-好友会员数
*
* @return
*/
@RequestMapping("customer-info")
@IgnoreLogin
public HaobanResponse customerInfo(@RequestBody @Valid CommonQO qo) {
return resultResponse(HaoBanErrCode.ERR_1);
}
} }
...@@ -2,17 +2,22 @@ package com.gic.haoban.manage.web.controller; ...@@ -2,17 +2,22 @@ package com.gic.haoban.manage.web.controller;
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.commons.web.qo.PageQo;
import com.gic.haoban.base.api.common.PageResult2; import com.gic.haoban.base.api.common.PageResult2;
import com.gic.haoban.common.utils.EntityUtil; import com.gic.haoban.common.utils.EntityUtil;
import com.gic.haoban.common.utils.HaobanResponse; import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.common.utils.PageUtil; import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.manage.api.dto.notify.dto.NoticeMessageInfoDTO;
import com.gic.haoban.manage.api.dto.notify.dto.PendingTaskDetailDTO; import com.gic.haoban.manage.api.dto.notify.dto.PendingTaskDetailDTO;
import com.gic.haoban.manage.api.dto.notify.qdto.PendingListQDTO; import com.gic.haoban.manage.api.dto.notify.qdto.PendingListQDTO;
import com.gic.haoban.manage.api.enums.NoticeMessageCategoryTypeEnum;
import com.gic.haoban.manage.api.enums.PendingTaskTypeEnum; import com.gic.haoban.manage.api.enums.PendingTaskTypeEnum;
import com.gic.haoban.manage.api.service.notify.NoticeMessageApiService;
import com.gic.haoban.manage.api.service.notify.PendingTaskApiService; import com.gic.haoban.manage.api.service.notify.PendingTaskApiService;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode; import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.qo.CommonQO; import com.gic.haoban.manage.web.qo.CommonQO;
import com.gic.haoban.manage.web.qo.PendingListQO; import com.gic.haoban.manage.web.qo.PendingListQO;
import com.gic.haoban.manage.web.qo.notify.MessageListQO;
import com.gic.haoban.manage.web.vo.notify.PairValVO; import com.gic.haoban.manage.web.vo.notify.PairValVO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
...@@ -36,6 +41,9 @@ public class NotifyController extends WebBaseController { ...@@ -36,6 +41,9 @@ public class NotifyController extends WebBaseController {
@Autowired @Autowired
private PendingTaskApiService pendingTaskApiService; private PendingTaskApiService pendingTaskApiService;
@Autowired
private NoticeMessageApiService noticeMessageService;
/** /**
* 待办列表 * 待办列表
* *
...@@ -105,4 +113,56 @@ public class NotifyController extends WebBaseController { ...@@ -105,4 +113,56 @@ public class NotifyController extends WebBaseController {
} }
/**
* 今日待办列表 最多20条
*
* @return
*/
@RequestMapping("/message/list")
public HaobanResponse list(@RequestBody @Valid MessageListQO qo, PageQo pageQo) {
ServiceResponse<Page<NoticeMessageInfoDTO>> retPage = noticeMessageService.pageNoticeMessage(qo.getEnterpriseId(), qo.getStoreId(), qo.getClerkId(), qo.getCategoryType(), pageQo.getBasePageInfo());
return resultResponse(HaoBanErrCode.ERR_1, PageUtil.getPageInfo(retPage.getResult()));
}
/**
* 设置单条已读
*
* @return
*/
@RequestMapping("/message/read")
public HaobanResponse readSingle(Long noticeMessageId) {
noticeMessageService.updateReadFlagById(noticeMessageId);
return resultResponse(HaoBanErrCode.ERR_1);
}
/**
* 批量设置已读
*
* @return
*/
@RequestMapping("/message/all-read")
public HaobanResponse readAll(@RequestBody @Valid MessageListQO qo) {
noticeMessageService.updateWriteFlagByClerkId(qo.getEnterpriseId(), qo.getClerkId(), qo.getCategoryType());
return resultResponse(HaoBanErrCode.ERR_1);
}
/**
* 消息类别
*
* @return
*/
@RequestMapping("/message/category")
public HaobanResponse category(@RequestBody @Valid MessageListQO qo) {
List<PairValVO> ret = new ArrayList<PairValVO>();
NoticeMessageCategoryTypeEnum[] values = NoticeMessageCategoryTypeEnum.values();
for (NoticeMessageCategoryTypeEnum val : values) {
PairValVO vo = new PairValVO();
vo.setKey(String.valueOf(val.getType()));
vo.setName(val.getName());
ret.add(vo);
}
return resultResponse(HaoBanErrCode.ERR_1, ret);
}
} }
...@@ -53,6 +53,9 @@ public class MobileWebInterceptor extends HandlerInterceptorAdapter { ...@@ -53,6 +53,9 @@ public class MobileWebInterceptor extends HandlerInterceptorAdapter {
if (null != ignoreLogin) { if (null != ignoreLogin) {
return true; return true;
} }
if (true) {
return true;
}
WellDoneLoginDTO wellDoneLoginDTO = (WellDoneLoginDTO) AuthRequestWellDoneUtil.getLoginUser(); WellDoneLoginDTO wellDoneLoginDTO = (WellDoneLoginDTO) AuthRequestWellDoneUtil.getLoginUser();
if (wellDoneLoginDTO == null) { if (wellDoneLoginDTO == null) {
this.errorResult(httpServletResponse, HaoBanErrCode.ERR_30009); this.errorResult(httpServletResponse, HaoBanErrCode.ERR_30009);
......
package com.gic.haoban.manage.web.qo.notify;
import com.gic.haoban.manage.web.qo.CommonQO;
/**
* Created 2021/12/20.
*
* @author hua
*/
public class MessageListQO extends CommonQO {
private Integer categoryType = -1;
public Integer getCategoryType() {
return categoryType;
}
public void setCategoryType(Integer categoryType) {
this.categoryType = categoryType;
}
}
...@@ -78,4 +78,8 @@ ...@@ -78,4 +78,8 @@
interface="com.gic.haoban.manage.api.service.notify.PendingTaskApiService" timeout="10000" interface="com.gic.haoban.manage.api.service.notify.PendingTaskApiService" timeout="10000"
retries="0" check="false"/> retries="0" check="false"/>
<dubbo:reference id="noticeMessageApiService"
interface="com.gic.haoban.manage.api.service.notify.NoticeMessageApiService" timeout="10000"
retries="0" check="false"/>
</beans> </beans>
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