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;
}
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;
}
Aggregations