Search in sources :

Example 1 with UserInfoVo

use of com.code.server.login.vo.UserInfoVo in project summer by foxsugar.

the class DelegateRelataionServiceImpl method findUserInfo.

@Override
public UserInfoVo findUserInfo(long agentId, long userId) {
    AgentBean agentBean = RedisManager.getAgentRedisService().getAgentBean(agentId);
    logger.info("agentBean:{}", agentBean);
    int type = 0;
    if (agentBean.getChildList().contains(userId)) {
        if (RedisManager.getAgentRedisService().isExit(userId)) {
            // 2级
            type = 2;
        } else {
            // 直接
            type = 1;
        }
    } else {
        for (long aid : agentBean.getChildList()) {
            if (RedisManager.getAgentRedisService().isExit(aid)) {
                AgentBean bean = RedisManager.getAgentRedisService().getAgentBean(aid);
                if (bean.getChildList().contains(userId)) {
                    // 三级
                    type = 3;
                    break;
                }
            }
        }
        if (userId == agentId) {
            type = 1;
        }
    }
    // //表示用户和该代理没有关系
    // if (type == 0){
    // return null;
    // }
    int userCount = 0;
    int delegateCount = 0;
    UserInfoVo userInfo = new UserInfoVo();
    userInfo.setType(type);
    if (type != 0) {
        User user = userDao.findOne(userId);
        userInfo.setReferee(user.getReferee());
        userInfo.setImage(user.getImage() + "/96");
        userInfo.setUsername(user.getUsername());
        userInfo.setCreateTime(DateUtil.convert2String(user.getRegistDate()));
        AgentBean bean = RedisManager.getAgentRedisService().getAgentBean(userId);
        if (bean != null) {
            for (long uid : bean.getChildList()) {
                if (RedisManager.getAgentRedisService().isExit(uid)) {
                    delegateCount++;
                    AgentBean aBean = RedisManager.getAgentRedisService().getAgentBean(uid);
                    for (long iUid : aBean.getChildList()) {
                        if (RedisManager.getAgentRedisService().isExit(iUid)) {
                            delegateCount++;
                        }
                    }
                } else {
                    userCount++;
                }
            }
            String today = DateUtil.convert2DayString(new Date());
            // 可用金额
            userInfo.setRebate(bean.getRebate());
            // 今日收益
            userInfo.setCanUseMoney(bean.getAgentInfo().getEveryDayRebate().get(today));
            // 累计收益
            userInfo.setTotalMoney(bean.getAgentInfo().getAllRebate());
        }
    }
    userInfo.setUserCount(userCount);
    userInfo.setDelegateCount(delegateCount);
    userInfo.setUserId(userId);
    return userInfo;
}
Also used : AgentBean(com.code.server.constant.game.AgentBean) User(com.code.server.db.model.User) Date(java.util.Date) UserInfoVo(com.code.server.login.vo.UserInfoVo)

Example 2 with UserInfoVo

use of com.code.server.login.vo.UserInfoVo in project summer by foxsugar.

the class DelegateRelataionAction method findSelfPlayerOrDelegates.

// 检查用户
@AuthChecker
@RequestMapping("/findUserInfo")
public AgentResponse findSelfPlayerOrDelegates(long userId) {
    ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
    HttpServletRequest request = attributes.getRequest();
    long agentId = AgentUtil.getAgentByRequest(request);
    UserInfoVo userInfo = delegateRelataionService.findUserInfo(agentId, userId);
    AgentResponse agentResponse = null;
    if (userInfo == null) {
        Map<String, Object> result = new HashMap<>();
        result.put("result", userInfo);
        agentResponse = new AgentResponse(NOT_SELF_USER, result);
    } else {
        Map<String, Object> result = new HashMap<>();
        result.put("result", userInfo);
        agentResponse = new AgentResponse(200, result);
    }
    return agentResponse;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) HashMap(java.util.HashMap) ServletRequestAttributes(org.springframework.web.context.request.ServletRequestAttributes) UserInfoVo(com.code.server.login.vo.UserInfoVo) AuthChecker(com.code.server.login.anotation.AuthChecker) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

UserInfoVo (com.code.server.login.vo.UserInfoVo)2 AgentBean (com.code.server.constant.game.AgentBean)1 User (com.code.server.db.model.User)1 AuthChecker (com.code.server.login.anotation.AuthChecker)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ServletRequestAttributes (org.springframework.web.context.request.ServletRequestAttributes)1