Search in sources :

Example 1 with AgentInfo

use of com.code.server.constant.db.AgentInfo in project summer by foxsugar.

the class DemoAction method testClear.

// 清除返利
public void testClear() {
    AgentUser agentUser1 = agentUserDao.findOne(17);
    AgentInfo agentInfo = agentUser1.getAgentInfo();
    for (String key : agentInfo.getEveryDayCost().keySet()) {
        ChildCost childCost = agentInfo.getEveryDayCost().get(key);
        childCost.setPartner(1);
    }
    agentUserDao.save(agentUser1);
}
Also used : ChildCost(com.code.server.constant.db.ChildCost) AgentInfo(com.code.server.constant.db.AgentInfo)

Example 2 with AgentInfo

use of com.code.server.constant.db.AgentInfo in project summer by foxsugar.

the class DemoAction method testTest.

public void testTest() {
    AgentUser agentUser1 = agentUserDao.findOne(17);
    AgentInfo agentInfo = agentUser1.getAgentInfo();
    // 计算累计收入
    double totalMoney = 0;
    double firstLevel = 0;
    double secondLevel = 0;
    for (String key : agentInfo.getEveryDayCost().keySet()) {
        ChildCost childCost = agentInfo.getEveryDayCost().get(key);
        if (childCost.getPartner() - 0d == 1d) {
            totalMoney += childCost.firstLevel;
            totalMoney += childCost.secondLevel;
        } else {
            firstLevel += childCost.getFirstLevel();
            secondLevel += childCost.getSecondLevel();
        }
    }
}
Also used : ChildCost(com.code.server.constant.db.ChildCost) AgentInfo(com.code.server.constant.db.AgentInfo)

Example 3 with AgentInfo

use of com.code.server.constant.db.AgentInfo in project summer by foxsugar.

the class DemoAction method testRecord.

public void testRecord() {
    AgentUser agentUser1 = agentUserDao.findOne(17);
    AgentInfo agentInfo = agentUser1.getAgentInfo();
    Map<String, ChildCost> rs = new HashMap<>();
    List<Map<String, ChildCost>> list = new ArrayList<>();
    for (String key : agentInfo.getEveryDayCost().keySet()) {
        ChildCost childCost = agentInfo.getEveryDayCost().get(key);
        if (childCost.getPartner() - 0d == 1d) {
            rs.put(key, childCost);
            list.add(rs);
        }
    }
    System.out.println("====");
    System.out.println(list);
}
Also used : ChildCost(com.code.server.constant.db.ChildCost) AgentInfo(com.code.server.constant.db.AgentInfo)

Example 4 with AgentInfo

use of com.code.server.constant.db.AgentInfo in project summer by foxsugar.

the class TodayChargeAction method showCost.

@AuthChecker
@RequestMapping("/dCost")
public AgentResponse showCost(String start, String end) {
    // 转化为标准字符串
    logger.info("dCost==========start:{},end:{}", start, end);
    start = DateUtil.becomeStandardSTime(start);
    end = DateUtil.becomeStandardSTime(end);
    logger.info("dCost==========start:{},end:{}", start, end);
    ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
    HttpServletRequest request = attributes.getRequest();
    long agentId = AgentUtil.getAgentByRequest(request);
    List<String> list = DateUtil.getDateListIn(end, start);
    AgentBean agentBean = RedisManager.getAgentRedisService().getAgentBean(agentId);
    AgentInfo agentInfo = agentBean.getAgentInfo();
    List<DChildCostVo> li = new ArrayList<>();
    double oneLevel = 0d;
    double twoLevel = 0d;
    double threeLevel = 0d;
    for (String dateStr : list) {
        ChildCost childCost = agentInfo.getEveryDayCost().get(dateStr);
        DChildCostVo dChildCostVo = new DChildCostVo();
        if (childCost != null) {
            BeanUtils.copyProperties(childCost, dChildCostVo);
        }
        dChildCostVo.setDateStr(dateStr);
        li.add(dChildCostVo);
        oneLevel += dChildCostVo.getFirstLevel();
        twoLevel += dChildCostVo.getSecondLevel();
        threeLevel += dChildCostVo.getThirdLevel();
    }
    // double total = oneLevel * 0.2 * 0.01 + twoLevel * 0.1 * 0.01 + threeLevel *0.1 * 0.01;
    double total = (oneLevel + twoLevel + threeLevel) * 0.01;
    Map<String, Object> result = new HashMap<>();
    result.put("li", li);
    result.put("total", total);
    // result.put("oneLevel", oneLevel * 0.2 * 0.01);
    // result.put("twoLevel", twoLevel * 0.1 * 0.01);
    // result.put("threeLevel", threeLevel *0.1 * 0.01);
    result.put("oneLevel", oneLevel * 0.01);
    result.put("twoLevel", twoLevel * 0.01);
    result.put("threeLevel", threeLevel * 0.01);
    result.put("start", list.get(list.size() - 1));
    result.put("end", list.get(0));
    double income = oneLevel * 0.2 * 0.01 + twoLevel * 0.1 * 0.01 + threeLevel * 0.1 * 0.01;
    result.put("income", income);
    AgentResponse agentResponse = new AgentResponse(200, result);
    return agentResponse;
}
Also used : ServletRequestAttributes(org.springframework.web.context.request.ServletRequestAttributes) HttpServletRequest(javax.servlet.http.HttpServletRequest) AgentBean(com.code.server.constant.game.AgentBean) ChildCost(com.code.server.constant.db.ChildCost) AgentInfo(com.code.server.constant.db.AgentInfo) AuthChecker(com.code.server.login.anotation.AuthChecker) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with AgentInfo

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

Aggregations

AgentInfo (com.code.server.constant.db.AgentInfo)10 ChildCost (com.code.server.constant.db.ChildCost)7 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 UserBean (com.code.server.constant.game.UserBean)3 ServerConfig (com.code.server.login.config.ServerConfig)3 AgentInfoRecord (com.code.server.constant.db.AgentInfoRecord)2 AgentBean (com.code.server.constant.game.AgentBean)2 ResponseVo (com.code.server.constant.response.ResponseVo)2 IOException (java.io.IOException)2 Element (org.dom4j.Element)2 AgentUser (com.code.server.db.model.AgentUser)1 AuthChecker (com.code.server.login.anotation.AuthChecker)1 HomeChargeVo (com.code.server.login.vo.HomeChargeVo)1 HomePageVo (com.code.server.login.vo.HomePageVo)1 LocalDate (java.time.LocalDate)1 List (java.util.List)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 Test (org.junit.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 ServletRequestAttributes (org.springframework.web.context.request.ServletRequestAttributes)1