From 744594ef1a2f530fc3e86ea9dc48b62247f79420 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 19 五月 2020 17:13:23 +0800 Subject: [PATCH] 饿了么绘图,添加口碑 --- fanli/src/main/java/com/yeshi/fanli/service/impl/msg/UserSystemMsgServiceImpl.java | 50 +++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 45 insertions(+), 5 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/msg/UserSystemMsgServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/msg/UserSystemMsgServiceImpl.java index 5b10c5e..74348fa 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/msg/UserSystemMsgServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/msg/UserSystemMsgServiceImpl.java @@ -6,14 +6,18 @@ import javax.annotation.Resource; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import com.yeshi.fanli.dao.mybatis.UserInfoMapper; import com.yeshi.fanli.dao.mybatis.msg.UserSystemMsgMapper; import com.yeshi.fanli.entity.bus.msg.UserSystemMsg; import com.yeshi.fanli.entity.bus.msg.UserSystemMsgTypeEnum; import com.yeshi.fanli.entity.bus.user.UserInfo; import com.yeshi.fanli.entity.system.SystemZnx; import com.yeshi.fanli.exception.msg.UserSystemMsgException; +import com.yeshi.fanli.service.inter.msg.UserMsgReadStateService; import com.yeshi.fanli.service.inter.msg.UserSystemMsgService; +import com.yeshi.fanli.service.inter.user.SystemZnxService; import com.yeshi.fanli.util.StringUtil; @Service @@ -22,6 +26,16 @@ @Resource private UserSystemMsgMapper userSystemMsgMapper; + @Resource + private UserMsgReadStateService userMsgReadStateService; + + @Resource + private UserInfoMapper userInfoMapper; + + @Resource + private SystemZnxService systemZnxService; + + @Transactional(rollbackFor=Exception.class) @Override public void addUserSystemMsg(Long uid, UserSystemMsgTypeEnum type, String title, String content, int timeTag, SystemZnx sz) throws UserSystemMsgException { @@ -29,7 +43,7 @@ throw new UserSystemMsgException(1, "淇℃伅涓嶅畬鏁�"); UserSystemMsg msg = new UserSystemMsg(); if (sz != null) { - if (userSystemMsgMapper.selectBySystemZNXId(sz.getId()) == null) { + if (userSystemMsgMapper.selectBySystemZNXId(sz.getId(), uid) == null) { msg.setCreateTime(new Date(sz.getCreateTime())); msg.setRead(false); msg.setSolved(false); @@ -37,6 +51,8 @@ msg.setUser(new UserInfo(uid)); msg.setType(type); msg.setTimeTag(timeTag); + msg.setTitle(sz.getTitle()); + msg.setContent(sz.getContent()); } else throw new UserSystemMsgException(1, "娑堟伅宸插瓨鍦�"); } else { @@ -50,15 +66,17 @@ msg.setTimeTag(timeTag); } userSystemMsgMapper.insertSelective(msg); + userMsgReadStateService.addSystemMsgUnReadCount(uid, 1); } @Override public UserSystemMsg getLatestUserSystemMsg(Long uid) { UserSystemMsg msg = userSystemMsgMapper.selectLatestUserSystemMsg(uid); - if (msg.getSystemZNX() != null) { - msg.setTitle(msg.getSystemZNX().getTitle()); - msg.setContent(msg.getSystemZNX().getContent()); - } + if (msg != null) + if (msg.getSystemZNX() != null) { + msg.setTitle(msg.getSystemZNX().getTitle()); + msg.setContent(msg.getSystemZNX().getContent()); + } return msg; } @@ -98,4 +116,26 @@ userSystemMsgMapper.setMsgReadByUid(uid); } + @Override + public void syncSystemZNX(Long uid) { + UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid); + if (user == null) + return; + long createTime = user.getCreatetime(); + List<SystemZnx> list = systemZnxService.listbyCreateTime(createTime); + if (list != null && list.size() > 0) { + for (SystemZnx znx : list) { + UserSystemMsg msg = userSystemMsgMapper.selectBySystemZNXId(znx.getId(), uid); + if (msg == null) + try { + addUserSystemMsg(uid, UserSystemMsgTypeEnum.common, null, null, UserSystemMsg.TIME_TAG_COMMON, + znx); + } catch (UserSystemMsgException e) { + e.printStackTrace(); + } + } + + } + } + } -- Gitblit v1.8.0