| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.xcong.excoin.common.contants.AppContants; |
| | | import com.xcong.excoin.configurations.RabbitMqConfig; |
| | | import com.xcong.excoin.modules.member.dao.MemberSettingDao; |
| | | import com.xcong.excoin.modules.otc.dao.OtcMsgHistoryDao; |
| | | import com.xcong.excoin.modules.otc.dao.OtcMsgUserListDao; |
| | | import com.xcong.excoin.modules.otc.entity.OtcMsgHistoryEntity; |
| | |
| | | |
| | | @Slf4j |
| | | @Component |
| | | //@ConditionalOnProperty(prefix = "app", name = "rabbit-consumer", havingValue = "true") |
| | | @ConditionalOnProperty(prefix = "app", name = "websocket-job", havingValue = "true") |
| | | public class ChatConsumer { |
| | | |
| | | @Autowired |
| | |
| | | |
| | | @Autowired |
| | | private RedisUtils redisUtils; |
| | | |
| | | @Autowired |
| | | private MemberSettingDao memberSettingDao; |
| | | |
| | | @RabbitListener(queues = RabbitMqConfig.QUEUE_MSG_HISTORY) |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | OtcMsgUserListEntity fromList = otcMsgUserListDao.selectChatListByToAndFrom(toId, fromId); |
| | | if (fromList == null) { |
| | | OtcMsgUserListEntity from = new OtcMsgUserListEntity(); |
| | | from.setMemberId(toId); |
| | | from.setTargetId(fromId); |
| | | from.setMemberId(fromId); |
| | | from.setTargetId(toId); |
| | | from.setIsRead(OtcMsgUserListEntity.ISREAD_TWO); |
| | | from.setLastMsgTime(new Date()); |
| | | otcMsgUserListDao.insert(from); |
| | | } else { |
| | | fromList.setLastMsgTime(new Date()); |
| | | otcMsgUserListDao.updateById(fromList); |
| | | } |
| | | |
| | | // 收件人是否存在聊天框 |
| | |
| | | toList.setLastMsgTime(new Date()); |
| | | otcMsgUserListDao.updateById(toList); |
| | | } else { |
| | | toList.setIsRead(OtcMsgUserListEntity.ISREAD_TWO); |
| | | toList.setIsRead(OtcMsgUserListEntity.ISREAD_ONE); |
| | | toList.setLastMsgTime(new Date()); |
| | | otcMsgUserListDao.updateById(toList); |
| | | } |
| | |
| | | fromHistory.setIsSelf(OtcMsgHistoryEntity.ISSELF_ONE); |
| | | fromHistory.setMemberId(fromId); |
| | | |
| | | memberSettingDao.updateMessageReminderByMemberId(toId); |
| | | |
| | | otcMsgHistoryDao.insert(fromHistory); |
| | | otcMsgHistoryDao.insert(toHistory); |
| | | } |