1
zj
5 days ago d98c7875c62e6551ad8aee081242aad8d5f13efe
src/main/java/com/nq/service/impl/AgentUserServiceImpl.java
@@ -18,6 +18,8 @@
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;
@@ -89,7 +91,7 @@
    }
    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("验证码不能为空");
//        }
@@ -111,8 +113,37 @@
        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;
    }
@@ -453,6 +484,7 @@
        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);