xuhy
2024-11-09 e360c48dccb05305936c6e81e0409965bd48a93e
xinquan-auth/src/main/java/com/xinquan/auth/service/SysLoginService.java
@@ -6,6 +6,7 @@
import com.xinquan.auth.form.AppLoginBody;
import com.xinquan.auth.form.AppRegisterBody;
import com.xinquan.auth.form.VerifyResultVO;
import com.xinquan.auth.util.HuaWeiSMSUtil;
import com.xinquan.common.core.constant.CacheConstants;
import com.xinquan.common.core.constant.Constants;
import com.xinquan.common.core.constant.SecurityConstants;
@@ -199,7 +200,7 @@
        sysUser.setUserName(cellPhone);
        sysUser.setUserType("01");
        sysUser.setNickName(nickname);
        sysUser.setPassword(password);
        sysUser.setPassword(SecurityUtils.encryptPassword(password));
        R<SysUser> registerResult = remoteUserService.registerAppUserInfo(sysUser, SecurityConstants.INNER);
        if (R.FAIL == registerResult.getCode())
@@ -210,10 +211,13 @@
        recordLogService.recordLogininfor(cellPhone, Constants.REGISTER, "注册成功");
        //TODO 默认头像待完善
        AppUserDTO appUserDTO = AppUserDTO.builder().userId(sysUser.getUserId()).cellPhone(cellPhone)
                .avatar("qwer").nickname(
                        nickname).userStatus(1).sanskritFlag(2).balance(BigDecimal.ZERO)
                .avatar("https://xqgwzh.obs.cn-south-1.myhuaweicloud.com/Logo%E7%A1%AE%E8%AE%A4%E7%89%88%281%29.jpg").nickname(
                        nickname).userStatus(1).sanskritFlag(2).balance(BigDecimal.ZERO).inviteUserId(appRegisterBody.getInviteUserId())
                .income(BigDecimal.ZERO).totalEnergyValue(0).registerTime(
                        LocalDateTime.now()).levelSettingId(1).build();
        if (appRegisterBody.getInviteUserId()!=null){
            appUserDTO.setInviteUserTime(LocalDateTime.now());
        }
        R<AppUser> result = remoteAppUserService.registerAppUser(appUserDTO,
                SecurityConstants.INNER);
        if (R.FAIL == result.getCode()) {
@@ -270,6 +274,8 @@
                return CacheConstants.APP_VERIFY_CAPTCHA_CODE_PREFIX;
            case 5:
                return CacheConstants.APP_CHANGE_PHONE_CODE_PREFIX;
            case 6:
                return CacheConstants.ADD_CARD_PHONE_CODE_PREFIX;
            default:
                return "";
        }
@@ -289,8 +295,8 @@
                    TimeUnit.MINUTES);
            log.info("发送验证码成功,手机号:{} 验证码:{}", cellPhone, code);
            // TODO 修改sender参数及templateId
            // HuaWeiSMSUtil.sendSms("[\"" + code + "\"]", cellPhone, "8823121426646",
            //         "cf1707ec44694627b1b483b0277e12fd");
             HuaWeiSMSUtil.sendSms("[\"" + code + "\"]", cellPhone, "8823121426646",
                     "767ad27dce184a32a4b4863517fbd301\n");
        } catch (Exception e) {
            log.error("发送短信失败", e);
            throw new ServiceException("验证码发送失败");
@@ -340,9 +346,10 @@
                    "登录用户不存在");
            throw new ServiceException("登录用户:" + body.getCellPhone() + " 不存在");
        }
        if (!sysUser.getPassword().equals(body.getPassword())){
            throw new ServiceException("密码错误");
        }
        passwordService.validate(sysUser, body.getPassword());
//        if (!sysUser.getPassword().equals(body.getPassword())){
//            throw new ServiceException("密码错误");
//        }
        AppLoginUser appLoginUser = new AppLoginUser();
        appLoginUser.setAppUserId(appUser.getId());
        appLoginUser.setCellPhone(appUser.getCellPhone());