Commit c787af15 by 吴博

feat: [1005883] 小睿消息优化

parent b46dd8e9
......@@ -107,11 +107,11 @@ public class TemplateConsr {
}
}
public void sendTempletMessage4Project(String keyword1, String keyword2, Long wechatUserId, String pagepath) {
public void sendTempletMessage4Project(String keyword1, String keyword2, Long wechatUserId, String pagepath, String first) {
LOGGER.info("小睿宠物发送模板消息业务进度提醒keyword1:{},keyword2:{}, wechatUserId:{},pagepath:{},",
keyword1, keyword2,wechatUserId, pagepath);
Map<String, String> temParam = new HashMap<>();
temParam.put("first", "主人召回提醒");
temParam.put("first", first);
temParam.put("keyword1", keyword1);
temParam.put("keyword2", keyword2);
temParam.put("remark", "点击查看详情");
......
......@@ -539,6 +539,20 @@ public class ReaderConsr {
}
return userGradeLabelIdDTO;
}
public List<Long> getAllRelateUnionUsers(List<Long> subList, Long operateOfficalId) {
LOGGER.info("【获取指定用户的关联公众号用户id ,<START>.[subList]");
List<Long> wechatUserIds = new ArrayList<>();
try {
wechatUserIds = ResponseHandleUtil.parseList(raysUnionUserService.getAllRelateUnionUsers(subList, operateOfficalId), Long.class);
} catch (Exception e) {
LOGGER.warn("raysUnionUserService.getAllRelateUnionUsers" + e.getMessage(), e);
}
return wechatUserIds;
}
}
......@@ -38,6 +38,7 @@ import com.pcloud.book.cultivate.entity.AppletNotifySendDTO;
import com.pcloud.book.cultivate.entity.CultivateNotify;
import com.pcloud.book.cultivate.entity.CultivateNotifyItem;
import com.pcloud.book.cultivate.entity.CultivateNotifySend;
import com.pcloud.book.cultivate.enums.NotifyMessageType;
import com.pcloud.book.cultivate.enums.NotifySendTypeEnum;
import com.pcloud.book.group.tools.SendWeixinRequestTools;
import com.pcloud.book.util.common.ThreadPoolUtils;
......@@ -54,6 +55,7 @@ import com.pcloud.common.utils.ServeLinkUtils;
import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.contentcenter.resource.dto.ResourceDTO;
import com.pcloud.readercenter.applet.entity.AppletQuestion;
import com.pcloud.readercenter.common.utils.ReaderConstants;
import com.pcloud.readercenter.wechat.dto.MiniUserDto;
import com.pcloud.readercenter.wechat.dto.ReaderMessageDto;
import com.pcloud.resourcecenter.product.dto.ProductDto;
......@@ -123,8 +125,13 @@ public class CultivateNotifyBizImpl implements CultivateNotifyBiz {
cultivateNotify.setTitle(cultivateNotifyDTO.getTitle());
cultivateNotify.setSendType(cultivateNotifyDTO.getSendType());
cultivateNotify.setShowHome(cultivateNotifyDTO.getShowHome());
cultivateNotify.setSquareImg(cultivateNotifyDTO.getSquareImg());
cultivateNotify.setAgentId(null==cultivateNotifyDTO.getAgentId()?0L:cultivateNotifyDTO.getAgentId());
cultivateNotifyDao.insert(cultivateNotify);
//合并消息
if (!ListUtils.isEmpty(cultivateNotifyDTO.getJumpNotifyItems())) {
cultivateNotifyDTO.getCultivateNotifyItems().addAll(cultivateNotifyDTO.getJumpNotifyItems());
}
cultivateNotifyDTO.getCultivateNotifyItems().forEach(a->a.setMessageId(cultivateNotify.getMessageId()));
cultivateNotifyItemDao.insert(cultivateNotifyDTO.getCultivateNotifyItems());
ThreadPoolUtils.SEND_NOTIFY_POOL.execute(()->{
......@@ -165,10 +172,19 @@ public class CultivateNotifyBizImpl implements CultivateNotifyBiz {
PageBeanNew<CultivateNotifyDTO> pageBeanNew= cultivateNotifySendDao.listPageNew(new PageParam(currentPage, numPerPage), map, "getNotifyListByType");
List<CultivateNotifyItem> cultivateNotifyItemList = new ArrayList<>();
for (CultivateNotifyDTO cultivateNotifyDTO:pageBeanNew.getRecordList()) {
List<CultivateNotifyItem> cultivateNotifyItems = new ArrayList<>();
List<CultivateNotifyItem> list1=cultivateNotifyItemDao.getNotifyItemsByMessageId(cultivateNotifyDTO.getMessageId());
fillResource(list1);
List<CultivateNotifyItem> list2=cultivateNotifyItemDao.getNotifyItemsByMessageId4Jump(cultivateNotifyDTO.getMessageId());
if (!ListUtils.isEmpty(list1)) {
cultivateNotifyItems.addAll(list1);
}
if (!ListUtils.isEmpty(list2)) {
cultivateNotifyItems.addAll(list2);
}
fillResource(cultivateNotifyItems);
cultivateNotifyDTO.setCultivateNotifyItems(list1);
cultivateNotifyItemList.addAll(list1);
cultivateNotifyDTO.setJumpNotifyItems(list2);
cultivateNotifyItemList.addAll(cultivateNotifyItems);
}
ThreadPoolUtils.OTHER_THREAD_POOL.execute(() -> {
//批量更新消息已读未读
......@@ -271,8 +287,14 @@ public class CultivateNotifyBizImpl implements CultivateNotifyBiz {
cultivateNotifySendList.add(cultivateNotifySend);
}
cultivateNotifySendDao.insert(cultivateNotifySendList);
//1005883【优化】平台端-消息通知管理-发布站内消息优化,小睿新鲜事支持模板消息推送 改成公众号模板消息推送
sendAppletTemplateMessage(cultivateNotifySendList, cultivateNotify.getAgentId(), null);
//根据小程序用户id查找对用的23用户id,并推送模板消息
/* if (NotifyMessageType.SYSTEM.code.equals(cultivateNotifyDTO.getMessageType())) {
sendOfficeTemplateMessage4Notify(cultivateNotifyDTO.getTitle(), subList);
}*/
}
}
}
//全局发送
......@@ -339,12 +361,31 @@ public class CultivateNotifyBizImpl implements CultivateNotifyBiz {
cultivateNotifySendList.add(cultivateNotifySend);
}
cultivateNotifySendDao.insert(cultivateNotifySendList);
sendAppletTemplateMessage(cultivateNotifySendList, cultivateNotify.getAgentId(), null);
if (NotifyMessageType.SYSTEM.code.equals(cultivateNotifyDTO.getMessageType())) {
sendOfficeTemplateMessage4Notify(cultivateNotifyDTO.getTitle(), subList);
}
}
}
}
}
private void sendOfficeTemplateMessage4Notify(String title, List<Long> subList) {
if (ListUtils.isEmpty(subList)) {
return;
}
List<Long> wechatUserIds = readerConsr.getAllRelateUnionUsers(subList, BookProps.getOperateOfficalId());
if (ListUtils.isEmpty(wechatUserIds)) {
return;
}
wechatUserIds.stream().forEach(wechatUserId -> {
String text1 = "小睿新鲜事";
String text2 = title;
String first = "推送消息提醒";
String page = "pages/notify/message/index";
templateConsr.sendTempletMessage4Project(text1, text2, wechatUserId, page, first);
});
}
/**
* 发送小程序模板消息
* @param list
......@@ -397,11 +438,17 @@ public class CultivateNotifyBizImpl implements CultivateNotifyBiz {
List<Long> messageIds = list.stream().filter(a -> null != a.getMessageId()).map(a -> a.getMessageId()).distinct().collect(Collectors.toList());
Map<Long, String> titleMap=new HashMap<>();
Map<Long, List<CultivateNotifyItem>> itemMap=new HashMap<>();
Map<Long, List<CultivateNotifyItem>> jumpMap=new HashMap<>();
if(!ListUtils.isEmpty(messageIds)){
/* List<CultivateNotify> cultivateNotifies = cultivateNotifyDao.getByIds(messageIds);
titleMap= cultivateNotifies.stream().collect(Collectors.toMap(a -> a.getMessageId(), a -> a.getTitle(), (k1, k2) -> k2));*/
List<CultivateNotifyItem> cultivateNotifyItems = cultivateNotifyItemDao.getByMessageIds(messageIds);
itemMap= cultivateNotifyItems.stream().collect(Collectors.groupingBy(a -> a.getMessageId()));
List<CultivateNotifyItem> jumplist = cultivateNotifyItemDao.getNotifyItemsByMessageIds4Jump(messageIds);
if (!ListUtils.isEmpty(jumplist)) {
jumpMap= jumplist.stream().collect(Collectors.groupingBy(a -> a.getMessageId()));
}
}
List<CultivateNotifyItem> cultivateNotifyItems = new ArrayList<>();
for (CultivateNotifyPageDTO cultivateNotifyPageDTO : list) {
......@@ -411,10 +458,16 @@ public class CultivateNotifyBizImpl implements CultivateNotifyBiz {
if(MapUtils.isNotEmpty(itemMap) && itemMap.containsKey(cultivateNotifyPageDTO.getMessageId())){
cultivateNotifyPageDTO.setCultivateNotifyItems(itemMap.get(cultivateNotifyPageDTO.getMessageId()));
}
if(MapUtils.isNotEmpty(jumpMap) && jumpMap.containsKey(cultivateNotifyPageDTO.getMessageId())){
cultivateNotifyPageDTO.setJumpNotifyItems(jumpMap.get(cultivateNotifyPageDTO.getMessageId()));
}
if(!ListUtils.isEmpty(cultivateNotifyPageDTO.getCultivateNotifyItems())){
fillResource(cultivateNotifyPageDTO.getCultivateNotifyItems());
cultivateNotifyItems.addAll(cultivateNotifyPageDTO.getCultivateNotifyItems());
}
if(!ListUtils.isEmpty(cultivateNotifyPageDTO.getJumpNotifyItems())){
cultivateNotifyItems.addAll(cultivateNotifyPageDTO.getJumpNotifyItems());
}
}
//填充资讯应用作品
fillAppOrProduct4Notify(cultivateNotifyItems);
......@@ -627,10 +680,19 @@ public class CultivateNotifyBizImpl implements CultivateNotifyBiz {
PageBeanNew<CultivateNotifyDTO> pageBeanNew= cultivateNotifySendDao.listPageNew(new PageParam(currentPage, numPerPage), map, "getNotifyListByType");
List<CultivateNotifyItem> cultivateNotifyItemList = new ArrayList<>();
for (CultivateNotifyDTO cultivateNotifyDTO:pageBeanNew.getRecordList()) {
List<CultivateNotifyItem> cultivateNotifyItems = new ArrayList<>();
List<CultivateNotifyItem> list1=cultivateNotifyItemDao.getNotifyItemsByMessageId(cultivateNotifyDTO.getMessageId());
fillResource(list1);
List<CultivateNotifyItem> list2=cultivateNotifyItemDao.getNotifyItemsByMessageId4Jump(cultivateNotifyDTO.getMessageId());
if (!ListUtils.isEmpty(list1)) {
cultivateNotifyItems.addAll(list1);
}
if (!ListUtils.isEmpty(list2)) {
cultivateNotifyItems.addAll(list2);
}
fillResource(cultivateNotifyItems);
cultivateNotifyDTO.setCultivateNotifyItems(list1);
cultivateNotifyItemList.addAll(list1);
cultivateNotifyDTO.setJumpNotifyItems(list2);
cultivateNotifyItemList.addAll(cultivateNotifyItems);
}
//填充资讯应用作品问题
fillAppOrProduct4Notify(cultivateNotifyItemList);
......@@ -709,17 +771,38 @@ public class CultivateNotifyBizImpl implements CultivateNotifyBiz {
if(ListUtils.isEmpty(messageIds)){
return new ArrayList<>();
}
List<CultivateNotifyItem> cultivateNotifyItems = new ArrayList<>();
List<CultivateNotifyItem> list=cultivateNotifyItemDao.getByMessageIds(messageIds);
fillResource(list);
fillAppOrProduct4Notify(list);
Map<Long, List<CultivateNotifyItem>> cultivateNotifyItemMap = list.stream().collect(Collectors.groupingBy(CultivateNotifyItem::getMessageId));
List<CultivateNotifyItem> list2=cultivateNotifyItemDao.getNotifyItemsByMessageIds4Jump(messageIds);
if (!ListUtils.isEmpty(list)) {
cultivateNotifyItems.addAll(list);
}
if (!ListUtils.isEmpty(list2)) {
cultivateNotifyItems.addAll(list2);
}
fillResource(cultivateNotifyItems);
fillAppOrProduct4Notify(cultivateNotifyItems);
Map<Long, List<CultivateNotifyItem>> cultivateNotifyItemMap = new HashMap<>();
if (!ListUtils.isEmpty(list)) {
cultivateNotifyItemMap = list.stream().collect(Collectors.groupingBy(CultivateNotifyItem::getMessageId));
}
Map<Long, List<CultivateNotifyItem>> cultivateNotifyItemMap4Jump = new HashMap<>();
if (!ListUtils.isEmpty(list2)) {
cultivateNotifyItemMap4Jump = list2.stream().collect(Collectors.groupingBy(CultivateNotifyItem::getMessageId));
}
List<CultivateNotify> cultivateNotifyList = cultivateNotifyDao.getByIds(messageIds);
List<CultivateNotifyDTO> cultivateNotifyDTOList = new ArrayList<>();
Map<Long, List<CultivateNotifyItem>> finalCultivateNotifyItemMap = cultivateNotifyItemMap;
Map<Long, List<CultivateNotifyItem>> finalCultivateNotifyItemMap4Jump = cultivateNotifyItemMap4Jump;
cultivateNotifyList.stream().forEach(e -> {
CultivateNotifyDTO notifyDTO= new CultivateNotifyDTO();
BeanUtils.copyProperties(e, notifyDTO);
notifyDTO.setCultivateNotifyItems(cultivateNotifyItemMap.get(e.getMessageId()));
notifyDTO.setCultivateNotifyItems(finalCultivateNotifyItemMap.get(e.getMessageId()));
if (MapUtils.isNotEmpty(finalCultivateNotifyItemMap4Jump) && !ListUtils.isEmpty(finalCultivateNotifyItemMap4Jump.get(e.getMessageId()))) {
notifyDTO.setJumpNotifyItems(finalCultivateNotifyItemMap4Jump.get(e.getMessageId()));
}
cultivateNotifyDTOList.add(notifyDTO);
});
ThreadPoolUtils.OTHER_THREAD_POOL.execute(() -> {
......
......@@ -242,6 +242,7 @@ public class CultivateRaysBizImpl implements CultivateRaysBiz {
Map<String, String> tempMap = new HashMap<>();
String text1 = "主人~我快要饿晕了";
String text2 = "快来,还可以抢救下!";
String first = "主人召回提醒";
if ("pro".equals(BookProps.getSystemEnv())) {
tempMap.put("thing3", text1);
tempMap.put("thing2", text2);
......@@ -253,7 +254,7 @@ public class CultivateRaysBizImpl implements CultivateRaysBiz {
//发送小程序服务消息
templateConsr.sendAppletMessageQueue(appletTemplateMessage);
//发送公众号模板消息
templateConsr.sendTempletMessage4Project(text1, text2, wechatUserId, appletTemplateMessage.getPage());
templateConsr.sendTempletMessage4Project(text1, text2, wechatUserId, appletTemplateMessage.getPage(),first);
}
/**
......
......@@ -12,4 +12,8 @@ public interface CultivateNotifyItemDao extends BaseDao<CultivateNotifyItem> {
List<CultivateNotifyItem> getNotifyItemsByMessageId(Long messageId);
List<CultivateNotifyItem> getByMessageIds(List<Long> messageIds);
List<CultivateNotifyItem> getNotifyItemsByMessageId4Jump(Long messageId);
List<CultivateNotifyItem> getNotifyItemsByMessageIds4Jump(List<Long> messageIds);
}
......@@ -24,4 +24,15 @@ public class CultivateNotifyItemDaoImpl extends BaseDaoImpl<CultivateNotifyItem>
map.put("messageIds",messageIds);
return super.getSqlSession().selectList(getStatement("getByMessageIds"), map);
}
@Override
public List<CultivateNotifyItem> getNotifyItemsByMessageId4Jump(Long messageId) {
return super.getSessionTemplate().selectList(getStatement("getNotifyItemsByMessageId4Jump"),messageId);
}
@Override
public List<CultivateNotifyItem> getNotifyItemsByMessageIds4Jump(List<Long> messageIds) {
return super.getSessionTemplate().selectList(getStatement("getNotifyItemsByMessageIds4Jump"),messageIds);
}
}
\ No newline at end of file
......@@ -43,6 +43,10 @@ public class CultivateNotifyDTO {
@ApiModelProperty("发送内容")
private List<CultivateNotifyItem> cultivateNotifyItems;
@ApiModelProperty("跳转选择的应用作品")
private List<CultivateNotifyItem> jumpNotifyItems;
@ApiModelProperty("用户id")
private List<WechatUserDTO> wechatUserDTOS;
......@@ -64,4 +68,7 @@ public class CultivateNotifyDTO {
@ApiModelProperty("是否首页弹窗")
private Integer showHome;
@ApiModelProperty("首页推图")
private String squareImg;
}
......@@ -26,6 +26,10 @@ public class CultivateNotifyPageDTO {
@ApiModelProperty("发送内容")
private List<CultivateNotifyItem> cultivateNotifyItems;
@ApiModelProperty("跳转选择的应用作品")
private List<CultivateNotifyItem> jumpNotifyItems;
@ApiModelProperty("发送时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date sendTime;
......@@ -33,4 +37,6 @@ public class CultivateNotifyPageDTO {
@ApiModelProperty("是否首页弹窗")
private Integer showHome;
private String squareImg;
}
......@@ -27,4 +27,7 @@ public class CultivateNotify extends BaseEntity {
@ApiModelProperty("是否首页弹窗")
private Integer showHome;
@ApiModelProperty("首页推图")
private String squareImg;
}
......@@ -10,10 +10,11 @@
<result column="send_type" property="sendType" jdbcType="INTEGER" />
<result column="agent_id" property="agentId" jdbcType="BIGINT" />
<result column="show_home" property="showHome" jdbcType="TINYINT" />
<result column="square_img" property="squareImg" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
message_id, message_type, title, create_time,update_time,send_type,agent_id, show_home
message_id, message_type, title, create_time,update_time,send_type,agent_id, show_home,square_img
</sql>
<insert id="insert" parameterType="com.pcloud.book.cultivate.entity.CultivateNotify" useGeneratedKeys="true" keyProperty="messageId">
......@@ -25,7 +26,8 @@
update_time,
send_type,
agent_id,
show_home
show_home,
square_img
)
values (
#{messageType},
......@@ -34,7 +36,8 @@
NOW(),
#{sendType},
#{agentId},
#{showHome}
#{showHome},
#{squareImg}
)
</insert>
......
......@@ -66,7 +66,7 @@
</insert>
<select id="getNotifyItemsByMessageId" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/> from cultivate_notify_item where message_id=#{messageId}
select <include refid="Base_Column_List"/> from cultivate_notify_item where message_id=#{messageId} and jump_type is null
</select>
<select id="getByMessageIds" parameterType="map" resultMap="BaseResultMap">
......@@ -77,6 +77,21 @@
<foreach collection="messageIds" open="(" close=")" separator="," item="item">
#{item}
</foreach>
and content_type &lt; 4
</select>
<select id="getNotifyItemsByMessageId4Jump" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/> from cultivate_notify_item where message_id=#{messageId} and jump_type is not null
</select>
<select id="getNotifyItemsByMessageIds4Jump" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/> from cultivate_notify_item
where
message_id in
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
and jump_type is not null
</select>
</mapper>
\ No newline at end of file
......@@ -143,7 +143,8 @@
a.message_id messageId,
a.create_time sendTime,
a.title title,
a.show_home showHome
a.show_home showHome,
a.square_img squareImg
from cultivate_notify a
<if test="keyword !=null">
LEFT JOIN cultivate_notify_item b on a.message_id=b.message_id
......
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