Search in sources :

Example 1 with AgentUser

use of com.code.server.db.model.AgentUser in project summer by foxsugar.

the class IChargeDaoTest method findOne.

@Test
public void findOne() {
    // AgentUser agentUser = agentUserDao.findOne(27);
    // AgentInfo agentInfo = agentUser.getAgentInfo();
    // System.out.println(agentInfo);
    AgentUser agentUser = agentUserDao.findOne(10334);
    System.out.println(agentUser);
}
Also used : AgentUser(com.code.server.db.model.AgentUser) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with AgentUser

use of com.code.server.db.model.AgentUser in project summer by foxsugar.

the class AgentUserService method list.

public Page<AgentUser> list(int page, int size) {
    List<AgentUser> list = new ArrayList<>();
    PageRequest pageRequest = new PageRequest(page, size);
    return agentUserDao.findAll(pageRequest);
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) ArrayList(java.util.ArrayList) AgentUser(com.code.server.db.model.AgentUser)

Example 3 with AgentUser

use of com.code.server.db.model.AgentUser in project summer by foxsugar.

the class AgentService method change2Partner.

/**
 * 改变为合伙人
 *
 * @param userId
 */
public void change2Partner(long userId) {
    AgentBean agentBean = RedisManager.getAgentRedisService().getAgentBean(userId);
    String unionId = userService.getUserDao().getOpenIdById(userId);
    // 如果不是代理,先成为代理
    if (agentBean == null) {
        agentBean = player2Agnet(userId, unionId);
    }
    // 已经是合伙人 返回
    if (agentBean.getIsPartner() == 1)
        return;
    // 如果有上级代理
    long parentId = agentBean.getParentId();
    if (parentId != 0) {
        AgentBean parentAgentBean = RedisManager.getAgentRedisService().getAgentBean(parentId);
        // 删掉这个下级代理
        parentAgentBean.getChildList().remove(userId);
        RedisManager.getAgentRedisService().updateAgentBean(parentAgentBean);
    }
    // 自己变成合伙人
    agentBean.setIsPartner(1);
    // 合伙人id 改成自己
    agentBean.setPartnerId(userId);
    // 上级变为0
    agentBean.setParentId(0);
    RedisManager.getAgentRedisService().updateAgentBean(agentBean);
    // user 上的改变 把上级去掉
    changePlayerReferee(userId, 0);
    // 自己下级的合伙人 全部改成自己
    Set<AgentBean> allChild = new HashSet<>();
    findAllClildAgent(agentBean, allChild);
    for (AgentBean subAgentBean : allChild) {
        subAgentBean.setPartnerId(userId);
        // 加入保存列表
        RedisManager.getAgentRedisService().updateAgentBean(subAgentBean);
    }
    // 在agent_user 生产合伙人表
    AgentUser agentUser = agentUserService.agentUserDao.findAgentUserByUsername("" + userId);
    if (agentUser == null) {
        agentUser = new AgentUser();
        agentUser.setCreateTime(new Date()).setUsername("" + userId).setPassword("" + userId).setLevel(1);
        agentUserService.agentUserDao.save(agentUser);
    }
}
Also used : AgentBean(com.code.server.constant.game.AgentBean) AgentUser(com.code.server.db.model.AgentUser) LocalDate(java.time.LocalDate)

Example 4 with AgentUser

use of com.code.server.db.model.AgentUser in project summer by foxsugar.

the class IChargeDaoTest method test.

@Test
public void test() {
    List<AgentUser> list = (List<AgentUser>) agentUserDao.findAll();
    for (AgentUser agentUser : list) {
        AgentInfo agentInfo = new AgentInfo();
        AgentInfoRecord agentInfoRecord = new AgentInfoRecord();
        agentUser.setAgentInfo(agentInfo);
        agentUser.setAgentInfoRecord(agentInfoRecord);
        agentUserDao.save(agentUser);
    }
}
Also used : List(java.util.List) AgentInfo(com.code.server.constant.db.AgentInfo) AgentInfoRecord(com.code.server.constant.db.AgentInfoRecord) AgentUser(com.code.server.db.model.AgentUser) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with AgentUser

use of com.code.server.db.model.AgentUser in project summer by foxsugar.

the class IAgentUserDaoTest method test.

@Test
public void test() {
    System.out.println(agentUserDao);
    System.out.println(agentUserDao.findAll());
    AgentUser agentUser = agentUserDao.findOne(10334);
    System.out.println(agentUser);
}
Also used : AgentUser(com.code.server.db.model.AgentUser) Test(org.junit.Test)

Aggregations

AgentUser (com.code.server.db.model.AgentUser)5 Test (org.junit.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 AgentInfo (com.code.server.constant.db.AgentInfo)1 AgentInfoRecord (com.code.server.constant.db.AgentInfoRecord)1 AgentBean (com.code.server.constant.game.AgentBean)1 LocalDate (java.time.LocalDate)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 PageRequest (org.springframework.data.domain.PageRequest)1