Search in sources :

Example 6 with AgentBean

use of com.code.server.constant.game.AgentBean in project summer by foxsugar.

the class DemoAction method assembleDelegateRelationship.

public Map<String, Object> assembleDelegateRelationship(long agentId, List<User> aList, List<User> bList) {
    Map<String, Object> nodeRoot = new HashMap<>();
    nodeRoot.put("name", transformStr(agentId));
    List<Object> childrenRoot = new ArrayList<>();
    nodeRoot.put("children", childrenRoot);
    Map<String, Object> node1_1 = new HashMap<>();
    childrenRoot.add(node1_1);
    node1_1.put("name", "直接玩家");
    List<Object> children1_1 = new ArrayList<>();
    node1_1.put("children", children1_1);
    // 直接玩家
    for (User user : aList) {
        DChildVo childVo = new DChildVo();
        childVo.setName(transformStr(user));
        childVo.setValue((int) user.getId());
        children1_1.add(childVo);
    }
    Map<String, Object> node1_2 = new HashMap<>();
    childrenRoot.add(node1_2);
    node1_2.put("name", "二级代理");
    List<Object> children1_2 = new ArrayList<>();
    node1_2.put("children", children1_2);
    // 二级代理
    for (User user : bList) {
        Map<String, Object> node2_x = new HashMap<>();
        node2_x.put("name", transformStr(user));
        children1_2.add(node2_x);
        List<Object> child2_x = new ArrayList<>();
        node2_x.put("children", child2_x);
        // //三级代理
        // for (int j = 100; j < 110; j++){
        // DChildVo childVo = new DChildVo();
        // childVo.setValue(j);
        // childVo.setName("三级代理" + j);
        // child2_x.add(childVo);
        // }
        AgentBean agentBean = RedisManager.getAgentRedisService().getAgentBean(user.getId());
        if (agentBean == null)
            continue;
        for (Long id : agentBean.getChildList()) {
            DChildVo dChildVo = new DChildVo();
            dChildVo.setName(transformStr(id));
            child2_x.add(dChildVo);
        }
    }
    return nodeRoot;
}
Also used : AgentBean(com.code.server.constant.game.AgentBean) DChildVo(com.code.server.login.vo.DChildVo)

Example 7 with AgentBean

use of com.code.server.constant.game.AgentBean in project summer by foxsugar.

the class DemoAction method fetchDelegate.

@DemoChecker
@RequestMapping("/fetchDelegate")
public AgentResponse fetchDelegate(long userId) {
    if (userId == 0) {
        return fetchDelegates(1);
    }
    // GameAgent gameAgent = gameAgentDao.findOne(userId);
    GameAgent gameAgent = homeService.findOneDelegate(userId);
    List<GameAgentVo> list = new ArrayList<>();
    AgentResponse agentResponse = new AgentResponse();
    if (gameAgent == null) {
        agentResponse.setData(list);
        agentResponse.setCode(com.code.server.login.action.ErrorCode.ERROR);
        Map<String, Object> result = new HashMap<>();
        agentResponse.setMsg(" 没有记录 ");
        result.put("total", 0);
        result.put("list", list);
        agentResponse.setData(result);
    } else {
        GameAgentVo gameAgentVo = new GameAgentVo();
        // 手动设置上级代理id
        AgentBean agentBean = RedisManager.getAgentRedisService().getAgentBean(userId);
        gameAgent.setParentId(agentBean.getParentId());
        BeanUtils.copyProperties(gameAgent, gameAgentVo);
        gameAgentVo.setIsPartnerDes(gameAgent.getIsPartner() == 1 ? "合伙人" : "代理");
        list.add(gameAgentVo);
        Map<String, Object> result = new HashMap<>();
        result.put("total", 1);
        result.put("list", list);
        agentResponse.setData(result);
    }
    return agentResponse;
}
Also used : AgentBean(com.code.server.constant.game.AgentBean) GameAgentVo(com.code.server.login.vo.GameAgentVo) DemoChecker(com.code.server.login.anotation.DemoChecker) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with AgentBean

use of com.code.server.constant.game.AgentBean in project summer by foxsugar.

the class CenterService method saveAgent.

private static void saveAgent() {
    Set<String> agents = RedisManager.getAgentRedisService().getSaveAgents();
    if (agents != null) {
        GameAgentService gameAgentService = SpringUtil.getBean(GameAgentService.class);
        Set<String> removeList = new HashSet<>();
        agents.forEach(agent -> {
            long agentId = Long.valueOf(agent);
            AgentBean agentBean = RedisManager.getAgentRedisService().getAgentBean(agentId);
            if (agentBean != null) {
                GameAgent gameAgent = AgentService.agentBean2GameAgent(agentBean);
                gameAgentService.getGameAgentDao().save(gameAgent);
                if (gameAgent.getIsPartner() == 1) {
                    saveAgentRecord(agentBean);
                }
            }
            removeList.add(agent);
        });
        if (removeList.size() > 0) {
            RedisManager.getAgentRedisService().removeSaveAgent(removeList.toArray());
        }
    }
}
Also used : AgentBean(com.code.server.constant.game.AgentBean)

Example 9 with AgentBean

use of com.code.server.constant.game.AgentBean in project summer by foxsugar.

the class DelegateRelataionServiceImpl method fetchTwoLevelDelegateList.

@Override
public List<TwoLevelInfoVo> fetchTwoLevelDelegateList(long agentId) {
    AgentBean agentBean = RedisManager.getAgentRedisService().getAgentBean(agentId);
    logger.info("fetchTwoLevelDelegateList:agentBean{}", agentBean);
    List<Long> aList = new ArrayList<>();
    for (long uid : agentBean.getChildList()) {
        if (RedisManager.getAgentRedisService().isExit(uid)) {
            aList.add(uid);
        }
    }
    List<TwoLevelInfoVo> result = new ArrayList<>();
    List<User> userList = this.userDao.findUsersByIdIn(aList);
    for (User user : userList) {
        TwoLevelInfoVo twoLevelInfoVo = new TwoLevelInfoVo();
        twoLevelInfoVo.setImage(user.getImage() + "/96");
        twoLevelInfoVo.setUsername(user.getUsername());
        twoLevelInfoVo.setUid(user.getId());
        result.add(twoLevelInfoVo);
    }
    return result;
}
Also used : AgentBean(com.code.server.constant.game.AgentBean) User(com.code.server.db.model.User) ArrayList(java.util.ArrayList) TwoLevelInfoVo(com.code.server.login.vo.TwoLevelInfoVo)

Example 10 with AgentBean

use of com.code.server.constant.game.AgentBean 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)

Aggregations

AgentBean (com.code.server.constant.game.AgentBean)37 User (com.code.server.db.model.User)13 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 UserBean (com.code.server.constant.game.UserBean)6 WxErrorException (me.chanjar.weixin.common.exception.WxErrorException)6 Recommend (com.code.server.db.model.Recommend)5 WxMpUser (me.chanjar.weixin.mp.bean.result.WxMpUser)5 AgentUser (com.code.server.db.model.AgentUser)4 GameAgent (com.code.server.db.model.GameAgent)4 ChildCost (com.code.server.constant.db.ChildCost)3 LocalDate (java.time.LocalDate)3 ArrayList (java.util.ArrayList)3 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)3 AgentInfo (com.code.server.constant.db.AgentInfo)2 Charge (com.code.server.db.model.Charge)2 DemoChecker (com.code.server.login.anotation.DemoChecker)2 TextBuilder (com.code.server.login.wechat.builder.TextBuilder)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 Random (java.util.Random)2