| | |
| | | import com.nq.vo.admin.AdminCountVO; |
| | | import com.nq.vo.agent.AgentInfoVO; |
| | | import com.nq.vo.agent.AgentSecondInfoVO; |
| | | import cn.hutool.extra.qrcode.QrCodeUtil; |
| | | import cn.hutool.extra.qrcode.QrConfig; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | |
| | | } |
| | | |
| | | |
| | | public ServerResponse login(String agentPhone, String agentPwd, String verifyCode, HttpServletRequest request) { |
| | | public ServerResponse login(String agentPhone, String agentPwd, String verifyCode, Integer googleAuthCode, HttpServletRequest request) { |
| | | // if (StringUtils.isBlank(verifyCode)) { |
| | | // return ServerResponse.createByErrorMsg("验证码不能为空"); |
| | | // } |
| | |
| | | if (agentUser.getIsLock().intValue() == 1) { |
| | | return ServerResponse.createByErrorMsg("登陆失败,您的账号已被锁定!"); |
| | | } |
| | | if (Boolean.TRUE.equals(agentUser.getGoogleAuthBind()) && googleAuthCode == null) { |
| | | return ServerResponse.createByErrorMsg("谷歌验证码不能为空"); |
| | | } |
| | | if (Boolean.TRUE.equals(agentUser.getGoogleAuthBind())) { |
| | | long t = System.currentTimeMillis(); |
| | | GoogleAuthenticator ga = new GoogleAuthenticator(); |
| | | ga.setWindowSize(5); |
| | | boolean userFlag = ga.check_code(agentUser.getGoogleAuthSecret(), Long.valueOf(googleAuthCode), t); |
| | | if (!userFlag) { |
| | | return ServerResponse.createByErrorMsg("谷歌验证码错误!"); |
| | | } |
| | | } |
| | | |
| | | return ServerResponse.createBySuccess(agentUser); |
| | | } |
| | | |
| | | @Override |
| | | public GoogleAuthDto getGoogleAuth(HttpServletRequest request) { |
| | | AgentUser agentUser = getCurrentAgent(request); |
| | | if (agentUser == null) { |
| | | return null; |
| | | } |
| | | String secretKey = GoogleAuthenticator.generateSecretKey(); |
| | | QrConfig config = new QrConfig(345, 345); |
| | | config.setMargin(3); |
| | | String content = String.format("otpauth://totp/%s?secret=%s", agentUser.getAgentName(), secretKey); |
| | | String base64 = QrCodeUtil.generateAsBase64(content, config, "png"); |
| | | GoogleAuthDto dto = new GoogleAuthDto(); |
| | | dto.setGoogleAuthImg(base64); |
| | | dto.setGoogleAuthSecret(secretKey); |
| | | return dto; |
| | | } |
| | | |
| | | |
| | |
| | | AgentUser parentAgent = this.agentUserMapper.selectByPrimaryKey(parentId); |
| | | if (parentId != null && parentId>0) { |
| | | if (parentAgent != null) { |
| | | if(parentAgent.getAgentLevel()>=6){ |
| | | return ServerResponse.createByErrorMsg("六级代理不能添加下级"); |
| | | } |
| | | agentUser.setParentId(parentAgent.getId()); |
| | | agentUser.setParentName(parentAgent.getAgentName()); |
| | | agentUser.setAgentLevel(parentAgent.getAgentLevel()+1); |
| | | //判断代理等级 |
| | | StockConfig stockConfig = iStockConfigServices.queryByKey(EConfigKey.AGENT_MAX_GRADE.getCode()); |
| | | Integer configLevel = Integer.parseInt(stockConfig.getCValue()); |
| | | if(agentUser.getAgentLevel() > configLevel){ |
| | | return ServerResponse.createByErrorMsg("代理最大等级为"+stockConfig.getCValue()); |
| | | } |
| | | |
| | | } else { |
| | | //总代理默认0级 |
| | | agentUser.setAgentLevel(Integer.valueOf(0)); |
| | |
| | | if (parentAgent != null) { |
| | | dbAgent.setParentId(parentAgent.getId()); |
| | | dbAgent.setParentName(parentAgent.getAgentName()); |
| | | dbAgent.setAgentLevel(parentAgent.getAgentLevel()+1); |
| | | //判断代理等级 |
| | | StockConfig stockConfig = iStockConfigServices.queryByKey(EConfigKey.AGENT_MAX_GRADE.getCode()); |
| | | if(null != agentUser.getAgentLevel() && agentUser.getAgentLevel() > Integer.parseInt(stockConfig.getCValue())){ |
| | | if(dbAgent.getAgentLevel() > Integer.parseInt(stockConfig.getCValue())){ |
| | | return ServerResponse.createByErrorMsg("代理最大等级为"+stockConfig.getCValue()); |
| | | } |
| | | dbAgent.setAgentLevel(parentAgent.getAgentLevel()+1); |
| | | |
| | | } else { |
| | | //总代理默认0级 |
| | | dbAgent.setAgentLevel(Integer.valueOf(0)); |
| | |
| | | agentInfoVO.setParentName(agentUser.getParentName()); |
| | | agentInfoVO.setTotalMoney(agentUser.getTotalMoney()); |
| | | agentInfoVO.setOnLineServices(agentUser.getOnLineServices()); |
| | | agentInfoVO.setGoogleAuthBind(Boolean.TRUE.equals(agentUser.getGoogleAuthBind())); |
| | | |
| | | String pcUrl = host + PropertiesUtil.getProperty("site.pc.reg.url") + agentUser.getAgentCode(); |
| | | agentInfoVO.setPcUrl(pcUrl); |