Explorar el Código

用户提现判断有误

udream-cxs hace 4 años
padre
commit
f294b57791

+ 0 - 175
lift-chat-service/src/main/java/cn/com/ty/chat/neety/process/ChatProcessor.java

@@ -45,28 +45,7 @@ public class ChatProcessor extends WebSoketSupport implements ProcessorInterface
 
         //redis只存当天的消息,RedisTask中synRedisChatToDB定时任务会在每天凌晨把消息同步到数据库
         //每次发消息,把消息累加到redis中,推送全量数据给客户端
-        /*boolean exists = redis.exists("ALLCHATS:" + sessionId);
-        List<IMMessage> chats = null;
-        if (exists){
-            chats = redis.get("ALLCHATS:" + sessionId, List.class);
-        } else {
-            chats  = new ArrayList() ;
-        }*/
-
-        /*List<IMMessage> chats = Optional.ofNullable(redis.get("ALLCHATS:" + sessionId, List.class)).orElse(new ArrayList());
-        chats.add(request);
-        redis.setValue("ALLCHATS:" + sessionId, chats);*/
         redis.lRightPush("ALLCHATS:" + sessionId, JSONObject.toJSONString(request));
-//        ChatMsgEntity entity = new ChatMsgEntity();
-//        entity.setMsg(request.getMsg());
-//        entity.setFromUser(request.getFromUser());
-//        entity.setToUser(request.getReceiver());
-//        entity.setType(request.getType());
-//        entity.setSessionid(request.getSessionid());
-//        entity.setStatuz(1);
-//        entity.setCreateBy(request.getName());
-//        entity.setCreateTime(new Date(request.getTime()).toInstant().atOffset(ZoneOffset.of("+8")).toLocalDateTime());
-//        msgService.save(entity);
 
         //更新聊天室中的最后一条记录及时间,在app中获取聊天室排序有用
         Optional.ofNullable(redis.get("ROOM:" + sessionId)).ifPresent(s -> {
@@ -80,10 +59,6 @@ public class ChatProcessor extends WebSoketSupport implements ProcessorInterface
                 }
             });
             redis.set("ROOM:" + sessionId, JSONObject.toJSONString(roomInfo));
-//        RoomInfo roomInfo = redis.get("ROOM:" + sessionId, RoomInfo.class);
-//        roomInfo.setLastChat(request.getMsg());
-//        roomInfo.setLastTime(request.getTime());
-//        redis.setValue("ROOM:" + sessionId, roomInfo);
             //通过redis获取房间信息
             //用户正常登录的时候链接就会调用login协议,login会加载聊天室与用户关系到数据
             //当用户已经登录了,附近的人聊天的时候,接收人是不知道自己已经有一个新的会话。
@@ -100,158 +75,8 @@ public class ChatProcessor extends WebSoketSupport implements ProcessorInterface
                     sendMessage(channel, request);
                 }
             }
-            /*if (request.getDataTable() == 3) {
-                //发给接收人
-                //如果接收人不在线,聊天记录存在redis中,等他上线之后进入聊天室同样也可以看到未读记录
-                Channel channel = userChannel.get(request.getReceiver());
-                if (null != channel) {
-                    sendMessage(channel, request);
-                }
-                //发给自己
-                sendMessage(client, request);
-            } else {
-                for (int i = 0; roomInfo.getUserLIst() != null
-                        && !roomInfo.getUserLIst().isEmpty()
-                        && i < roomInfo.getUserLIst().size(); i++) {
-                    UserInfo userInfo = roomInfo.getUserLIst().get(i);
-                    Channel channel = userChannel.get(userInfo.getUserId());
-
-                    if (null != channel) {
-                        sendMessage(channel, request);
-                    }
-                }
-            }*/
         });
 
-
-
-
-
-
-        /*
-        // 获取消息发送者
-        String username = request.getName();
-        String room = request.getSessionid();
-        String sendId = request.getFromUser();
-        String avatarUrl = request.getAvatarUrl();
-
-        if(null != request.getMsg()){
-            String message = SensitivewordFilter.replaceSensitiveWord(request.getMsg(), 1, "**");
-            request.setMsg(message);
-        }
-        
-        client.attr(IP_ADDR).getAndSet(getAddress(client));
-        client.attr(USERNAME).getAndSet(username);
-        client.attr(HEAD_PIC).getAndSet(avatarUrl);
-        client.attr(ROOM).getAndSet(room);
-        client.attr(SENDID).getAndSet(sendId);
-
-        // room为总得大房间,map中的key为小房间的房间号,值为房间内对应每个用户的对象
-        Map<String, List<RoomVo>> redisRoom = redis.get(MAX_ROOM, HashMap.class);
-        String txt = redis.getKey(MAX_ROOM);
-        Object ob = (txt == null || "null".equals(txt)) ? null : JSONObject.parseObject(txt, HashMap.class).get(room);
-
-        // 获取当前用户的小房间持有用户
-        Set<Channel> minRoom = new HashSet<>();
-     *//*   boolean flag = true;
-        // 确保单个用户服务端channel是唯一的,避免重复发送同一条消息
-        for (Channel channel : minRoom) {
-            if (channel == client) {
-                log.info(":{}==========:{}",channel,client);
-                flag = false;
-                continue;
-            }
-        }
-        if (flag) {
-            log.info("初始化channel .");
-            minRoom.add(client);
-        } else {
-            log.info("重复初始化channel .");
-        }*//*
-        
-
-        Set<HashMap<String, Channel>> userChannel = roomUserChannel.get(room);
-        Set<HashMap<String, Channel>> newUserChannel = new HashSet<>();
-        if (null != userChannel && userChannel.size() > 0) {
-
-            for (HashMap<String, Channel> map : userChannel) {
-
-                map.keySet().forEach(item -> {
-                    log.info("keySet():{}", item);
-                    if (item.equals(sendId)) {
-                        log.info("sendId:{}重连item存在:{}", sendId, item);
-                        map.put(item, client);
-                    } else if (!map.containsKey(sendId)) {
-                        log.info("重连sendId不存在:{}", sendId);
-                        map.put(sendId, client);
-
-                    }
-                    newUserChannel.add(map);
-                });
-
-            }
-
-            roomUserChannel.put(room, newUserChannel);
-        } else {
-            userChannel = new HashSet<>();
-            HashMap<String, Channel> map = new HashMap<>();
-            map.put(sendId, client);
-            userChannel.add(map);
-
-            // for (String session : DBsessionList) {
-            roomUserChannel.put(room, userChannel);
-            
-            log.info("====================================");
-            log.info("出现问题。Chat的时候roomUserChannel为空?");
-            log.info("====================================");
-            // }
-        }
-
-        for (Map<String, Channel> map : roomUserChannel.get(room)) {
-            map.values().forEach(item -> {
-                minRoom.add(item);
-                log.info("房间里面的channel:{}", item.id());
-            });
-            roomUser.put(room, minRoom);
-        }
-        
-
-        *//** 如果是聊天信息 *//*
-
-        ChatMsgDTO msgDb = null;
-        for (Channel channel : minRoom) {// 向房间内在线用户发送消息
-            if (channel != client) {
-                request.setName(username);
-                if (null == msgDb) {
-                    msgDb = saveMsg(request);
-                }
-
-            } else { *//** 向自己发送消息 *//*
-                request.setName(username);
-            }
-
-            sendMessage(channel, request);
-        }
-
-        if (null != ob) {*//** 向不在线的用户发送未读消息 *//*
-
-            List<RoomVo> voList = JSONArray.parseArray(ob.toString(), RoomVo.class);
-            for (RoomVo item : voList) {
-                if (!item.getFlag()) {
-                    // 用户不在线记录未读消息同时向缓存中写入聊天记录,供后期同步到数据库中
-                    if (null == msgDb) {
-                        msgDb = saveMsg(request);
-                    }
-                    item.getMsgList().add(msgDb);
-                    // 写入缓存对象
-                    redisRoom.put(room, voList);
-                }
-            }
-        }
-
-        // 更新缓存
-        redis.setValue(MAX_ROOM, redisRoom);*/
-
     }
 
 }

+ 1 - 195
lift-chat-service/src/main/java/cn/com/ty/chat/neety/process/InitRoomProcessor.java

@@ -33,20 +33,10 @@ public class InitRoomProcessor extends WebSoketSupport implements ProcessorInter
 
         String SESSION_ID = request.getSessionid();
         String USER_ID = request.getUserId();
-        /*//聊天室不存在返回消息
-        boolean exists = redis.exists("ROOM:" + SESSION_ID);
-        if (!exists){
-            IMMessage im = new IMMessage();
-            im.setCmd(IMP.CHAT.getName());
-            im.setMsg("房间不存在");
-            sendMessage(client, im);
-            return;
-        }*/
 
         //用户每次进来更新自己的信息
         //如果自己的信息不存在就把用户添加到聊天室中
         //如果聊天室存在,并且当前用户没有在聊天室中,把用户添加到聊天室中------start
-//        RoomInfo roomInfo = redis.get("ROOM:" + SESSION_ID, RoomInfo.class);
         Optional.ofNullable(redis.get("ROOM:" + SESSION_ID)).ifPresent(s -> {
             RoomInfo roomInfo = JSONObject.parseObject(s,RoomInfo.class);
             roomInfo.getUserList().forEach(userInfo -> {
@@ -57,38 +47,13 @@ public class InitRoomProcessor extends WebSoketSupport implements ProcessorInter
                     userInfo.setIsRed(0);
                 }
             });
-            /*boolean userExists = false;
-            for (int i = 0; roomInfo.getUserLIst() != null
-                    && !roomInfo.getUserLIst().isEmpty()
-                    && i < roomInfo.getUserLIst().size(); i++) {
-                if (currentUserId.equals(roomInfo.getUserLIst().get(i).getUserId())){
-                    userExists = true;
-                    roomInfo.getUserLIst().get(i).setAvatarUrl(currentUserHead);
-                    roomInfo.getUserLIst().get(i).setUserName(currentUserName);
-                    roomInfo.getUserLIst().get(i).setIsRed(0);
-                }
-            }
-            if (!userExists) {
-                UserInfo userInfo = new UserInfo();
-                userInfo.setUserId(currentUserId);
-                userInfo.setUserName(currentUserName);
-                userInfo.setAvatarUrl(currentUserHead);
-                roomInfo.getUserLIst().add(userInfo);
-            }*/
+
 
             redis.set("ROOM:" + SESSION_ID, JSONObject.toJSONString(roomInfo));
-//        redis.setValue("ROOM:" + SESSION_ID, roomInfo);
         });
-
         //如果聊天室存在,并且当前用户没有在聊天室中,把用户添加到聊天室中------end
 
         //用户每次进来把当天聊天记录通过后台全部推送过去
-//        List charts = redis.get("ALLCHATS:" + SESSION_ID, List.class);
-//        IMMessage im = new IMMessage();
-//        im.setCmd(IMP.INITROOM.getName());
-//        im.setMsg(JSONObject.toJSONString(charts));
-//        im.setSessionid(SESSION_ID);
-//        sendMessage(client, im);
         Optional.ofNullable(redis.lRange("ALLCHATS:" + SESSION_ID,0,-1)).ifPresent(strings -> {
             IMMessage im = new IMMessage();
             im.setCmd(IMP.INITROOM.getName());
@@ -96,165 +61,6 @@ public class InitRoomProcessor extends WebSoketSupport implements ProcessorInter
             im.setSessionid(SESSION_ID);
             sendMessage(client, im);
         });
-        /*
-        // 获取消息发送者
-        String username = request.getName();
-        String room = request.getSessionid();
-        String sendId = request.getFromUser();
-        String avatarUrl = request.getAvatarUrl();
-
-        client.attr(IP_ADDR).getAndSet(getAddress(client));
-        client.attr(USERID).getAndSet(getAddress(client));
-        client.attr(USERNAME).getAndSet(username);
-        client.attr(HEAD_PIC).getAndSet(avatarUrl);
-        client.attr(ROOM).getAndSet(room);
-        client.attr(SENDID).getAndSet(sendId);
-
-        // room为总得大房间,map中的key为小房间的房间号,值为房间内对应每个用户的对象
-        Map<String, List<RoomVo>> redisRoom = redis.get(MAX_ROOM, HashMap.class);
-        String txt = redis.getKey(MAX_ROOM);
-        Object ob = (txt == null || "null".equals(txt)) ? null : JSONObject.parseObject(txt, HashMap.class).get(room);
-
-        // 获取当前用户的小房间持有用户
-        Set<Channel> minRoom = new HashSet<>();
-        *//*
-        if (null != roomUser.get(room)) {
-            minRoom = roomUser.get(room);
-        } else {
-            minRoom = new HashSet<>();
-        }
-        boolean flag = true;
-        // 确保单个用户服务端channel是唯一的,避免重复发送同一条消息
-        for (Channel channel : minRoom) {
-            if (channel == client) {
-                flag = false;
-                continue;
-            }
-        }
-        if (flag) {
-            log.info("初始化channel .");
-            minRoom.add(client);
-        } else {
-            log.info("重复初始化channel .");
-        }
-        
-        // TODO 完成诊单之后将从缓存中删除房间
-        roomUser.put(room, minRoom);*//*
-
-        Set<HashMap<String, Channel>> userChannel = roomUserChannel.get(room);
-        Set<HashMap<String, Channel>> newUserChannel = new HashSet<>();
-        if (null != userChannel && userChannel.size() > 0) {
-            for (HashMap<String, Channel> map : userChannel) {
-                map.keySet().forEach(item -> {
-                    log.info("keySet():{}", item);
-                    if (item.equals(sendId)) {
-                        log.info("sendId:{}重连item存在:{}", sendId, item);
-                        map.put(item, client);
-                    } else if (!map.containsKey(sendId)) {
-                        log.info("重连sendId不存在:{}", sendId);
-                        map.put(sendId, client);
-                    }
-                    newUserChannel.add(map);
-                });
-
-            }
-
-            roomUserChannel.put(room, newUserChannel);
-        } else {
-            userChannel = new HashSet<>();
-            HashMap<String, Channel> map = new HashMap<>();
-            map.put(sendId, client);
-            userChannel.add(map);
-
-            // for (String session : DBsessionList) {
-            roomUserChannel.put(room, userChannel);
-            
-            log.info("====================================");
-            log.info("出现问题。InitRoom的时候roomUserChannel为空?");
-            log.info("====================================");
-            // }
-        }
-
-        for (Map<String, Channel> map : roomUserChannel.get(room)) {
-            map.values().forEach(item -> {
-                minRoom.add(item);
-                log.info("房间里面的channel:{}", item.id());
-            });
-            roomUser.put(room, minRoom);
-        }
-
-        List<RoomVo> voList = new ArrayList<>();
-        RoomVo vo = new RoomVo(sendId, 0, username, avatarUrl, true, room);
-
-        if (null != redisRoom) {// 缓存中获取全部房间信息
-
-            if (null == ob) {// 拿到当前房间号
-                voList.add(vo);
-                redisRoom.put(room, voList);
-            } else {
-
-                voList = JSONArray.parseArray(ob.toString(), RoomVo.class);
-                voList.add(vo);
-                voList = voList.stream().filter(distinctByKey(RoomVo::getUserId)).collect(Collectors.toList()); // 去重
-
-                for (RoomVo item : voList) {
-                    if (sendId.equals(item.getUserId())) {
-                        item.setAvatarUrl(avatarUrl);
-                        item.setFlag(true);
-                        item.setName(username);
-                    }
-                }
-
-                redisRoom.put(room, voList);
-            }
-
-        } else {
-            redisRoom = new HashMap<>();
-            voList.add(vo);
-            redisRoom.put(room, voList);
-        }
-        // 获取房间内的用户对象信息
-        String loginList = JSONObject.toJSONString(voList);
-
-        *//** 向所有用户发送系统消息 *//*
-        for (Channel channel : minRoom) {
-            if (channel != client) {
-                // 自定义系统消息格式
-                IMMessage requestSystem = new IMMessage(IMP.SYSTEM.getName(), sysTime(), 0, loginList);
-                sendMessage(channel, requestSystem);
-            } else if (channel == client) {*//** 向自己发送消 *//*
-
-         *//**
-         * 1、提取该用户所有房间的未读消息列表返回给用户 2、此处为登录初始化调用,不会频繁触发,所以直接查询mysql用的会话列表。来配合缓存读取用户的所有未读消息
-         *//*
-                if (null != ob) {
-                    voList = JSONArray.parseArray(ob.toString(), RoomVo.class);
-                    for (RoomVo item : voList) {
-                        *//** 提取未读消息列表返回给用户 *//*
-                        if (item.getMsgList().size() > 0 && item.getUserId().equals(sendId)) {
-                            request = new IMMessage(IMP.UNREAD.getName(), sysTime(), 0,
-                                JSONObject.toJSONString(item.getMsgList()));
-                            item.setMsgList(null);// 将未读消息置空
-                            sendMessage(channel, request);
-                            // 写入缓存对象
-                            redisRoom.put(room, voList);
-                        }
-                    }
-
-                }
-                log.info("发送消息~~~~~");
-                sendOnline(channel, loginList);
-
-            } else {
-
-                request = new IMMessage(IMP.SYSTEM.getName(), sysTime(), 0, loginList);
-                sendMessage(channel, request);
-                log.info("发送消息~~~~~");
-            }
-        }
-
-        // 更新缓存
-        redis.setValue(MAX_ROOM, redisRoom);*/
     }
 
 }

+ 0 - 155
lift-chat-service/src/main/java/cn/com/ty/chat/neety/process/LoginProcessor.java

@@ -40,161 +40,6 @@ public class LoginProcessor extends WebSoketSupport implements ProcessorInterfac
             logout(channel);
         });
         userChannel.put(USER_ID, client);
-
-
-//        // room为总得大房间,map中的key为小房间的房间号,值为房间内对应每个用户的对象
-//        Map<String, List<RoomVo>> redisRoom = redis.get(MAX_ROOM, HashMap.class);
-//        String txt = redis.getKey(MAX_ROOM);
-//
-//        Object ob = (txt == null || "null".equals(txt)) ? null : JSONObject.parseObject(txt, HashMap.class).get(room);
-//
-//
-//
-//
-//
-//
-//        // 获取当前用户的小房间持有用户
-//        Set<Channel> minRoom = new HashSet<>();
-//        // 当前用户有效的房间号
-//        List<String> DBsessionList = sessionService.findListByUserId(sendId);
-//        for (String dbSession : DBsessionList) {
-//            Set<HashMap<String, Channel>> userChannel = roomUserChannel.get(dbSession);
-//
-//            Set<HashMap<String, Channel>> newUserChannel = new HashSet<>();
-//            if (null != userChannel && userChannel.size() > 0) {
-//                for (HashMap<String, Channel> map : userChannel) {
-//                    map.keySet().forEach(item -> {
-//                        log.info("keySet():{}", item);
-//                        if (item.equals(sendId)) {
-//                            log.info("sendId:{}重连item存在:{}", sendId, item);
-//                            map.put(item, client);
-//                        } else if (!map.containsKey(sendId)) {
-//                            log.info("重连sendId不存在:{}", sendId);
-//                            map.put(sendId, client);
-//
-//                        }
-//                        newUserChannel.add(map);
-//                    });
-//
-//                }
-//
-//                roomUserChannel.put(dbSession, newUserChannel);
-//            } else {
-//                userChannel = new HashSet<>();
-//                HashMap<String, Channel> map = new HashMap<>();
-//                map.put(sendId, client);
-//                userChannel.add(map);
-//
-//                // for (String session : DBsessionList) {
-//                roomUserChannel.put(dbSession, userChannel);
-//                // }
-//            }
-//
-//        }
-//
-//        for (String dbSession : DBsessionList) {
-//            for (Map<String, Channel> map : roomUserChannel.get(dbSession)) {
-//                map.values().forEach(item -> {
-//                    minRoom.add(item);
-//                    log.info("房间里面的channel:{}", item.id());
-//                });
-//
-//            }
-//            roomUser.put(dbSession, minRoom);
-//        }
-//
-//        Map allMsg = JSONObject.parseObject(txt, HashMap.class);
-//        if (null != DBsessionList && null != allMsg) {
-//            /** 房间号所对应的用户信息 */
-//            List<RoomVo> voList = new ArrayList<>();
-//            // List<RoomVo> unreadList = new ArrayList<>();
-//            /** 未读消息列表 */
-//            Map<String, List<RoomVo>> unreadMap = new HashMap<>();
-//            /** 登录对象集合 */
-//            Map<String, List<RoomVo>> loginMap = new HashMap<>();
-//
-//            for (String sessionKey : DBsessionList) {
-//                Object keyValue = allMsg.get(sessionKey);
-//                List<RoomVo> unreadList = new ArrayList<>();
-//                RoomVo vo = new RoomVo(sendId, 0, username, avatarUrl, true, sessionKey);
-//                if (null != keyValue) {
-//
-//                    // 对应房间的用户信息
-//                    voList = JSONArray.parseArray(keyValue.toString(), RoomVo.class);
-//                    for (RoomVo item : voList) {
-//                        if (item.getUserId().equals(sendId)) {
-//
-//                            unreadList.add(item);
-//                        }
-//                    }
-//
-//                    if (null == ob) {// 拿到当前房间号
-//                        voList.add(vo);
-//                        redisRoom.put(room, voList);
-//                    } else {
-//
-//                        voList = JSONArray.parseArray(ob.toString(), RoomVo.class);
-//                        voList.add(vo);
-//                        voList = voList.stream().filter(distinctByKey(RoomVo::getUserId)).collect(Collectors.toList()); // 去重
-//                        // 设置该用户持有房间的在线状态
-//                        for (RoomVo item : voList) {
-//                            if (sendId.equals(item.getUserId())) {
-//                                item.setAvatarUrl(avatarUrl);
-//                                item.setFlag(true);
-//                                item.setName(username);
-//                            }
-//                        }
-//
-////                        redisRoom.put(sessionKey, voList);
-//                    }
-//                    // UNreadList.addAll(unreadList);
-//
-//                    // 组装在线消息
-//                    String loginList = JSONObject.toJSONString(voList);
-//
-//
-//                  /*  for (RoomVo item : voList) {
-//                        if (sendId.equals(item.getUserId())) {
-//                            item.setAvatarUrl(avatarUrl);
-//                            item.setFlag(true);
-//                            item.setName(username);
-//                        }
-//                    }*/
-//                    unreadMap.put(sessionKey, unreadList);
-//                    loginMap.put(sessionKey, voList);
-//
-//                    // 向我的所有房间发送上线消息
-//                    for (Channel item : roomUser.get(sessionKey)) {
-//
-//                        if (item != client) {
-//                            // 自定义系统消息格式
-//                            IMMessage requestSystem = new IMMessage(IMP.SYSTEM.getName(), sysTime(), 0, loginList);
-//                            sendMessage(item, requestSystem);
-//                        }
-//                    }
-//
-//                    // 写入缓存对象
-//                    redisRoom.put(sessionKey, voList);
-//                }
-//
-//            }
-//
-//            /** 向自己发送消 */
-//            // 组装 UNREAD消息
-//            request = new IMMessage(IMP.UNREAD.getName(), sysTime(), 0, JSONObject.toJSONString(unreadMap));
-//            // sendOnline(client, JSONObject.toJSONString(loginMap));
-//            sendMessage(client, request);
-//
-//            // 更新缓存中所有房间的未读消息列表,将未读消息置空
-//            for (RoomVo item : voList) {
-//                if (item.getMsgList().size() > 0 && item.getUserId().equals(sendId)) {
-//                    item.setMsgList(null);// 将未读消息置空
-//                }
-//            }
-//        }
-//
-//        // 更新缓存
-//        redis.setValue(MAX_ROOM, redisRoom);
     }
 
 }

+ 0 - 565
lift-chat-service/src/main/java/cn/com/ty/chat/neety/process/MsgProcessor.java

@@ -1,565 +0,0 @@
-package cn.com.ty.chat.neety.process;//package cn.com.ty.lift.ud.neety.process;
-//
-//import java.time.LocalDateTime;
-//import java.util.ArrayList;
-//import java.util.HashMap;
-//import java.util.HashSet;
-//import java.util.List;
-//import java.util.Map;
-//import java.util.Set;
-//import java.util.concurrent.ConcurrentHashMap;
-//import java.util.function.Function;
-//import java.util.function.Predicate;
-//import java.util.stream.Collectors;
-//
-//import cn.com.ty.lift.ud.chat.service.IChatSessionService;
-//import cn.com.ty.lift.ud.chat.service.impl.ChatSessionServiceImpl;
-//import cn.com.ty.lift.ud.utils.ApplicationContextUtil;
-//import cn.com.ty.lift.ud.redis.ChatDo;
-//import cn.com.ty.lift.ud.redis.RedisUtil;
-//import org.slf4j.Logger;
-//import org.slf4j.LoggerFactory;
-//import org.springframework.context.annotation.DependsOn;
-//import org.springframework.context.annotation.Lazy;
-//import org.springframework.stereotype.Component;
-//
-//import com.alibaba.fastjson.JSONArray;
-//import com.alibaba.fastjson.JSONObject;
-//
-//import cn.com.ty.lift.ud.neety.protocol.ChatMsgDTO;
-//import cn.com.ty.lift.ud.neety.protocol.IMDecoder;
-//import cn.com.ty.lift.ud.neety.protocol.IMEncoder;
-//import cn.com.ty.lift.ud.neety.protocol.IMMessage;
-//import cn.com.ty.lift.ud.neety.protocol.IMP;
-//import cn.com.ty.lift.ud.neety.protocol.RoomVo;
-//import io.netty.channel.Channel;
-//import io.netty.channel.group.ChannelGroup;
-//import io.netty.channel.group.DefaultChannelGroup;
-//import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
-//import io.netty.util.AttributeKey;
-//import io.netty.util.concurrent.GlobalEventExecutor;
-//
-///** 消息处理类 */
-//
-//@Deprecated
-//
-//@Lazy
-//@Component
-//@DependsOn("redisUtil")
-//public class MsgProcessor {
-//    /** 记录在线用户 */
-//    private static ChannelGroup onlineUsers = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
-//
-//    private static final Logger logger = LoggerFactory.getLogger(MsgProcessor.class);
-//
-//    /** 用户名 */
-//    private final AttributeKey<String> USERNAME = AttributeKey.valueOf("username");
-//    /** 头像 */
-//    private final AttributeKey<String> HEAD_PIC = AttributeKey.valueOf("headPic");
-//    /** ip */
-//    private final AttributeKey<String> IP_ADDR = AttributeKey.valueOf("ipAddr");
-//
-//    private final AttributeKey<JSONObject> ATTRS = AttributeKey.valueOf("attrs");
-//    /** 房间号 */
-//    private final AttributeKey<String> ROOM = AttributeKey.valueOf("ROOM");
-//    /** 当前用户id */
-//    private final AttributeKey<String> SENDID = AttributeKey.valueOf("SENDID");
-//    /** 小房间用户关系对应 */
-//    public static Map<String, Set<Channel>> roomUser = new HashMap<>();
-//    /** redis缓存 */
-//    private static RedisUtil redis = ApplicationContextUtil.getBean(RedisUtil.class);
-//
-//    private static IChatSessionService sessionService = ApplicationContextUtil.getBean(ChatSessionServiceImpl.class);
-//    /** 解析模式(本地测试为:false) */
-//    private final static boolean testFlag = true;
-//
-//    /**
-//     * websoket消息处理
-//     *
-//     * @param client
-//     * @param msg
-//     */
-//    public void process(Channel client, String msg) {
-//        // 将字符串解析为自定义格式
-//        IMMessage request = IMDecoder.decode(msg);
-//        if (null == request) {
-//            return;
-//        }
-//
-//        // 获取消息发送者
-//        String username = request.getName();
-//        String room = request.getSessionid();
-//        String sendId = request.getFromUser();
-//        String avatarUrl = request.getAvatarUrl();
-//
-//        client.attr(IP_ADDR).getAndSet(getAddress(client));
-//        client.attr(USERNAME).getAndSet(username);
-//        client.attr(HEAD_PIC).getAndSet(avatarUrl);
-//        client.attr(ROOM).getAndSet(room);
-//        client.attr(SENDID).getAndSet(sendId);
-//
-//        // room为总得大房间,map中的key为小房间的房间号,值为房间内对应每个用户的对象
-//        Map<String, List<RoomVo>> redisRoom = redis.get("ROOM", HashMap.class);
-//        String txt = redis.getKey("ROOM");
-//        Object ob = (txt == null || "null".equals(txt)) ? null : JSONObject.parseObject(txt, HashMap.class).get(room);
-//
-//        // 获取当前用户的小房间持有用户
-//        Set<Channel> minRoom = null;
-//        if (null != roomUser.get(room)) {
-//            minRoom = roomUser.get(room);
-//        } else {
-//            minRoom = new HashSet<>();
-//        }
-//        boolean flag = true;
-//        // 确保单个用户服务端channel是唯一的,避免重复发送同一条消息
-//        for (Channel channel : minRoom) {
-//            if (channel == client) {
-//                flag = false;
-//                continue;
-//            }
-//        }
-//        if (flag) {
-//            logger.info("初始化channel .");
-//            minRoom.add(client);
-//        } else {
-//            logger.warn("重复初始化channel .");
-//        }
-//
-//        // 初始化登录操作
-//        if (IMP.LOGINALL.getName().equals(request.getCmd())) {
-//
-//            /** 当前用户有效的房间号 */
-//            List<String> DBsessionList = sessionService.findListByUserId(sendId);
-//            for (String dbSession : DBsessionList) {
-//                roomUser.put(dbSession, minRoom);
-//            }
-//
-//            Map allMsg = JSONObject.parseObject(txt, HashMap.class);
-//            if (null != DBsessionList && null != allMsg) {
-//                /** 房间号所对应的用户信息 */
-//                List<RoomVo> voList = new ArrayList<>();
-//                /** 未读消息列表 */
-//                Map<String, List<RoomVo>> unreadMap = new HashMap<>();
-//                /** 登录对象集合 */
-//                Map<String, List<RoomVo>> loginMap = new HashMap<>();
-//                List<RoomVo> UNreadList = new ArrayList<>();
-//                for (String sessionKey : DBsessionList) {
-//                    Object keyValue = allMsg.get(sessionKey);
-//
-//                    if (null != keyValue) {
-//
-//                        // 对应房间的用户信息
-//                        voList = JSONArray.parseArray(keyValue.toString(), RoomVo.class);
-//                        UNreadList.addAll(voList);
-//                        // 组装在线消息
-//                        String loginList = JSONObject.toJSONString(voList);
-//
-//                        // 设置该用户持有房间的在线状态
-//                        for (RoomVo item : voList) {
-//                            if (sendId.equals(item.getUserId())) {
-//                                item.setAvatarUrl(avatarUrl);
-//                                item.setFlag(true);
-//                                item.setName(username);
-//                            }
-//                        }
-//                        unreadMap.put(sessionKey, voList);
-//                        loginMap.put(sessionKey, voList);
-//
-//                        // 向我的所有房间发送上线消息
-//                        for (Channel item : roomUser.get(sessionKey)) {
-//
-//                            if (item != client) {
-//                                // 自定义系统消息格式
-//                                IMMessage requestSystem = new IMMessage(IMP.SYSTEM.getName(), sysTime(), 0, loginList);
-//                                sendMessage(item, requestSystem);
-//                            }
-//                        }
-//                        // 更新缓存中所有房间的未读消息列表,将未读消息置空
-//                        for (RoomVo item : voList) {
-//                            if (item.getMsgList().size() > 0 && item.getUserId().equals(sendId)) {
-//                                item.setMsgList(null);// 将未读消息置空
-//                            }
-//                        }
-//
-//                        // 写入缓存对象
-//                        redisRoom.put(sessionKey, voList);
-//                    }
-//
-//                }
-//
-//                /** 向自己发送消 */
-//                // 组装 UNREAD消息
-//                request = new IMMessage(IMP.UNREAD.getName(), sysTime(), 0, JSONObject.toJSONString(unreadMap));
-//                // sendOnline(client, JSONObject.toJSONString(loginMap));
-//                sendMessage(client, request);
-//
-//            }
-//            // 如果诊单是登录动作
-//        } else if (IMP.INITROOM.getName().equals(request.getCmd())) {
-//
-//            // TODO 完成诊单之后将从缓存中删除房间
-//            roomUser.put(room, minRoom);
-//
-//            List<RoomVo> voList = new ArrayList<>();
-//            RoomVo vo = new RoomVo(sendId, 0, username, avatarUrl, true, room);
-//
-//            if (null != redisRoom) {// 缓存中获取全部房间信息
-//
-//                if (null == ob) {// 拿到当前房间号
-//                    voList.add(vo);
-//                    redisRoom.put(room, voList);
-//                } else {
-//
-//                    voList = JSONArray.parseArray(ob.toString(), RoomVo.class);
-//                    voList.add(vo);
-//                    voList = voList.stream().filter(distinctByKey(RoomVo::getUserId)).collect(Collectors.toList()); // 去重
-//
-//                    for (RoomVo item : voList) {
-//                        if (sendId.equals(item.getUserId())) {
-//                            item.setAvatarUrl(avatarUrl);
-//                            item.setFlag(true);
-//                            item.setName(username);
-//                        }
-//                    }
-//
-//                    redisRoom.put(room, voList);
-//                }
-//
-//            } else {
-//                redisRoom = new HashMap<>();
-//                voList.add(vo);
-//                redisRoom.put(room, voList);
-//            }
-//            // 获取房间内的用户对象信息
-//            String loginList = JSONObject.toJSONString(voList);
-//
-//            /** 向所有用户发送系统消息 */
-//            for (Channel channel : minRoom) {
-//                if (channel != client) {
-//                    // 自定义系统消息格式
-//                    IMMessage requestSystem = new IMMessage(IMP.SYSTEM.getName(), sysTime(), 0, loginList);
-//                    sendMessage(channel, requestSystem);
-//                } else {/** 向自己发送消 */
-//
-//                    /**
-//                     * 1、提取该用户所有房间的未读消息列表返回给用户 2、此处为登录初始化调用,不会频繁触发,所以直接查询mysql用的会话列表。来配合缓存读取用户的所有未读消息
-//                     */
-//
-//                    if (null != ob) {
-//                        voList = JSONArray.parseArray(ob.toString(), RoomVo.class);
-//                        for (RoomVo item : voList) {
-//                            /** 提取未读消息列表返回给用户 */
-//                            if (item.getMsgList().size() > 0 && item.getUserId().equals(sendId)) {
-//                                request = new IMMessage(IMP.UNREAD.getName(), sysTime(), 0,
-//                                    JSONObject.toJSONString(item.getMsgList()));
-//                                item.setMsgList(null);// 将未读消息置空
-//
-//                                // 写入缓存对象
-//                                redisRoom.put(room, voList);
-//                            }
-//                        }
-//                    } else {
-//
-//                        request = new IMMessage(IMP.SYSTEM.getName(), sysTime(), 0, loginList);
-//                    }
-//
-//                    logger.info("发送消息~~~~~");
-//                    sendOnline(channel, loginList);
-//                    sendMessage(channel, request);
-//
-//                    /*List<String> DBsessionList = sessionService.findListByUserId(sendId);
-//                    Map allMsg = JSONObject.parseObject(txt, HashMap.class);
-//                    if (null != DBsessionList && null != allMsg) {
-//
-//                        // 拿到该用户的所有房间的会话列表以及未读消息列表
-//                        List<RoomVo> UNreadList = new ArrayList<>();
-//                        Map<String, List<RoomVo>> unreadMap = new HashMap<>();
-//                        for (String sessionKey : DBsessionList) {
-//                            Object keyValue = allMsg.get(sessionKey);
-//
-//                            if (null != keyValue) {
-//                                voList = JSONArray.parseArray(keyValue.toString(), RoomVo.class);
-//                                unreadMap.put(sessionKey, voList);
-//                                UNreadList.addAll(voList);
-//                            }
-//
-//                        }
-//
-//                        // 组装 UNREAD消息
-//                        request = new IMMessage(IMP.UNREAD.getName(), sysTime(), 0, JSONObject.toJSONString(unreadMap));
-//
-//                        // 更新缓存中所有房间的未读消息列表
-//                        for (RoomVo item : UNreadList) {
-//                            if (item.getMsgList().size() > 0 && item.getUserId().equals(sendId)) {
-//                                item.setMsgList(null);// 将未读消息置空
-//                                // 写入缓存对象
-//                                redisRoom.put(room, voList);
-//                            }
-//                        }
-//                    } else {
-//
-//                        request = new IMMessage(IMP.SYSTEM.getName(), sysTime(), 0, loginList);
-//                    }
-//
-//                    logger.info("发送消息~~~~~");
-//                    sendOnline(channel, loginList);
-//                    sendMessage(channel, request);*/
-//
-//                }
-//
-//            }
-//
-//        } else if (IMP.LOGOUT.getName().equals(request.getCmd())) {/** 如果是登出 */
-//            logout(client);
-//        } else if (IMP.CHAT.getName().equals(request.getCmd())) {/** 如果是聊天信息 */
-//
-//            ChatMsgDTO msgDb = null;
-//            for (Channel channel : minRoom) {// 向房间内在线用户发送消息
-//                if (channel != client) {
-//                    request.setName(username);
-//                    if (null == msgDb) {
-//                        msgDb = saveMsg(request);
-//                    }
-//
-//                } else { /** 向自己发送消息 */
-//                    request.setName("MY_SELF");
-//                }
-//
-//                sendMessage(channel, request);
-//            }
-//
-//            if (null != ob) {/** 向不在线的用户发送未读消息 */
-//
-//                List<RoomVo> voList = JSONArray.parseArray(ob.toString(), RoomVo.class);
-//                for (RoomVo item : voList) {
-//                    if (!item.getFlag()) {
-//                        // 用户不在线记录未读消息同时向缓存中写入聊天记录,供后期同步到数据库中
-//                        if (null == msgDb) {
-//                            msgDb = saveMsg(request);
-//                        }
-//                        item.getMsgList().add(msgDb);
-//                        // 写入缓存对象
-//                        redisRoom.put(room, voList);
-//                    }
-//                }
-//            }
-//        }
-//
-//        // 更新缓存
-//        redis.setValue("ROOM", redisRoom);
-//
-//    }
-//
-//    /**
-//     * 向房间内在线用户发送其它人的在线状况
-//     *
-//     * @param channel
-//     * @param loginList
-//     */
-//    private void sendOnline(Channel channel, String loginList) {
-//        // 自定义IM协议解码
-//        IMMessage request = new IMMessage(IMP.SYSTEM.getName(), sysTime(), 0, loginList);
-//        String text = IMEncoder.toJsonString(request, testFlag);
-//        // 发送消息
-//        channel.writeAndFlush(new TextWebSocketFrame(text));
-//    }
-//
-//    /**
-//     * 发送文本消息
-//     *
-//     * @param channel
-//     * @param request
-//     */
-//    private void sendMessage(Channel channel, IMMessage request) {
-//        // 自定义IM协议解码
-//        String text = IMEncoder.toJsonString(request, testFlag);
-//        // 发送消息
-//        channel.writeAndFlush(new TextWebSocketFrame(text));
-//    }
-//
-//    private static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
-//        Set<Object> seen = ConcurrentHashMap.newKeySet();
-//        return t -> seen.add(keyExtractor.apply(t));
-//    }
-//
-//    /**
-//     * 提取缓存中还未同步到数据库的聊天记录,追加上新的聊天记录 如果缓存中没有历史聊天记录创建新的缓存对象
-//     *
-//     * @param request
-//     *            请求对象
-//     * @return 消息对象
-//     */
-//    private ChatMsgDTO saveMsg(IMMessage request) {
-//        if (redis.exists(request.getSessionid())) {/** 提取缓存中还未同步到数据库的聊天记录,追加上新的聊天记录 */
-//            ChatDo chatDo = redis.get(request.getSessionid(), ChatDo.class);
-//            return this.saveMsg(chatDo, request.getFromUser(), request.getMsg(), 1, request.getType(),
-//                request.getSessionid(), request.getName(), request.getAvatarUrl());
-//
-//        } else {/** 如果缓存中没有历史聊天记录创建新的缓存对象 */
-//            return this.saveMsg(new ChatDo(), request.getFromUser(), request.getMsg(), 1, request.getType(),
-//                request.getSessionid(), request.getName(), request.getAvatarUrl());
-//        }
-//    }
-//
-//    /**
-//     * 获取用户昵称
-//     *
-//     * @param client
-//     * @return
-//     */
-//    public String getNickName(Channel client) {
-//        return client.attr(USERNAME).get();
-//    }
-//
-//    /**
-//     * 获取用户远程IP地址
-//     *
-//     * @param client
-//     * @return
-//     */
-//    public String getAddress(Channel client) {
-//        return client.remoteAddress().toString().replaceFirst("/", "");
-//    }
-//
-//    /**
-//     * 获取扩展属性
-//     *
-//     * @param client
-//     * @return
-//     */
-//    public JSONObject getAttrs(Channel client) {
-//        try {
-//            return client.attr(ATTRS).get();
-//        } catch (Exception e) {
-//            return null;
-//        }
-//    }
-//
-//    /**
-//     * 获取扩展属性
-//     *
-//     * @param client
-//     * @return
-//     */
-//    private void setAttrs(Channel client, String key, Object value) {
-//        try {
-//            JSONObject json = client.attr(ATTRS).get();
-//            json.put(key, value);
-//            client.attr(ATTRS).set(json);
-//        } catch (Exception e) {
-//            JSONObject json = new JSONObject();
-//            json.put(key, value);
-//            client.attr(ATTRS).set(json);
-//        }
-//    }
-//
-//    /**
-//     * 登出通知
-//     *
-//     * @param client
-//     */
-//    public void logout(Channel client) {
-//        String room = client.attr(ROOM).get();
-//        String sendId = client.attr(SENDID).get();
-//        Map<String, List<RoomVo>> redisRoom = redis.get("ROOM", HashMap.class);
-//        String txt = redis.getKey("ROOM");
-//
-//        IMMessage request = new IMMessage();
-//        request.setName(client.attr(USERNAME).get());
-//        request.setCmd(IMP.SYSTEM.getName());
-//        request.setOnline(0);
-//        request.setSessionid(client.attr(ROOM).get());
-//
-//        Set<Channel> minRoom = null;
-//        if (null != roomUser.get(request.getSessionid())) {
-//            minRoom = roomUser.get(request.getSessionid());
-//        } else {
-//            minRoom = new HashSet<>();
-//        }
-//
-//        List<RoomVo> voList = new ArrayList<>();
-//        List<String> DBsessionList = sessionService.findListByUserId(sendId);
-//        if (null != DBsessionList) {
-//
-//            // 拿到该用户的所有房间的会话列表以及未读消息列表
-//            Map allMsg = JSONObject.parseObject(txt, HashMap.class);
-//            for (String sessionKey : DBsessionList) {
-//                Object keyValue = allMsg.get(sessionKey);
-//
-//                if (null != keyValue) {
-//                    voList = JSONArray.parseArray(keyValue.toString(), RoomVo.class);
-//                    for (RoomVo item : voList) {
-//                        if (item.getUserId().equals(sendId)) {
-//                            item.setFlag(false);
-//                        }
-//                    }
-//                    redisRoom.put(sessionKey, voList);
-//
-//                    String loginList = JSONObject.toJSONString(voList);
-//                    request.setMsg(loginList);
-//                    // 向小房间内的所有用户发送系统消息
-//                    for (Channel channel : minRoom) {
-//                        if (channel != client) {
-//                            // 发送消息
-//                            sendMessage(channel, request);
-//                        }
-//                    }
-//                }
-//
-//            }
-//
-//        }
-//
-//        // 更新缓存数据
-//        redis.setValue("ROOM", redisRoom);
-//
-//        // 删除用户信息
-//        minRoom.remove(client);
-//        // 当前小房间没有用户了。删除小房间
-//        if (minRoom.size() <= 0) {
-//            roomUser.remove(room);
-//        }
-//    }
-//
-//    /**
-//     * 系统当前时间
-//     *
-//     * @return
-//     */
-//    private long sysTime() {
-//        return System.currentTimeMillis();
-//    }
-//
-//    /**
-//     * 将聊天记录存入缓存中
-//     *
-//     * @param chatDo
-//     *            聊天记录
-//     * @param sendUserId
-//     *            发送人id
-//     * @param msg
-//     *            文本信息
-//     * @param status
-//     *            状态 0:正常1:屏蔽
-//     * @param type
-//     *            消息类型:1文本、2图片、3视频、4语音'
-//     * @param sessionid
-//     *            房间号号'
-//     */
-//    private ChatMsgDTO saveMsg(ChatDo chatDo, String sendUserId, String msg, Integer status, Integer type,
-//        String sessionid, String name, String avatarUrl) {
-//        ChatMsgDTO entity = new ChatMsgDTO();
-//        entity.setMsg(msg);
-//        entity.setStatuz(status);
-//        entity.setName(name);
-//        entity.setSessionid(sessionid);
-//        entity.setType(type);
-//        entity.setFromUser(sendUserId);
-//        entity.setAvatarUrl(avatarUrl);
-//        entity.setCreateTime(LocalDateTime.now().toString());
-//        chatDo.getList().add(entity);
-//
-//        redis.setValue(sessionid, chatDo);
-//        return entity;
-//    }
-//}

+ 0 - 17
lift-chat-service/src/main/java/cn/com/ty/chat/neety/process/WebLoginAllProcessor.java

@@ -56,20 +56,6 @@ public class WebLoginAllProcessor extends WebSoketSupport implements ProcessorIn
 
                 for (HashMap<String, Channel> map : userChannel) {
 
-                   /* map.forEach((key, value) -> {
-                        log.info("keySet():{}", key);
-                        if (key.equals(sendId)) {
-                            log.info("sendId:{}重连item存在:{}", sendId, key);
-                            map.put(key, client);
-                        } else if (!map.containsKey(sendId)) {
-                            log.info("重连sendId不存在:{}", sendId);
-                            map.put(sendId, client);
-
-                        }
-                        newUserChannel.add(map);
-
-                    });*/
-
                     map.keySet().forEach(item -> {
                         log.info("keySet():{}", item);
                         if (item.equals(sendId)) {
@@ -91,10 +77,7 @@ public class WebLoginAllProcessor extends WebSoketSupport implements ProcessorIn
                 HashMap<String, Channel> map = new HashMap<>();
                 map.put(sendId, client);
                 userChannel.add(map);
-
-                // for (String session : DBsessionList) {
                 roomUserChannel.put(dbSession, userChannel);
-                // }
             }
 
         }

+ 4 - 6
lift-ud-service/src/main/java/cn/com/ty/lift/ud/payment/service/impl/UserWithdrawServiceImpl.java

@@ -112,9 +112,8 @@ public class UserWithdrawServiceImpl extends ServiceImpl<UserWithdrawMapper, Use
             return RestResponse.fail("0", "提现金额必须大于零");
         }
 
-        QueryWrapper<UserInfoEntity> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("user_id", req.getUserId());
-        UserInfoEntity userInfo = userInfoMapper.selectOne(queryWrapper);
+        UserInfoEntity userInfo = userInfoMapper.selectOne(new QueryWrapper<UserInfoEntity>()
+                .eq("user_id", req.getUserId()));
 
         if (null == userInfo) {
             return RestResponse.fail("0", "所填用户不存在");
@@ -125,9 +124,8 @@ public class UserWithdrawServiceImpl extends ServiceImpl<UserWithdrawMapper, Use
         if (StringUtils.isBlank(userInfo.getAlipayRealName())) {
             return RestResponse.fail("400", "请先完善提现账号信息");
         }
-
-        if (userInfo.getBalance().compareTo(req.getAmount()) != 1) {
-            return RestResponse.fail("0", "平台账户余额不足,请及时充值");
+        if (userInfo.getBalance().compareTo(req.getAmount()) > -1) {
+            return RestResponse.fail("0", "账户余额不足,无法提现!");
         }
 
         //每月提现次数 和 单次提现金额都有限制