|
@@ -81,7 +81,10 @@ public class LoginService {
|
|
|
private AssoPersonVipMapper assoPersonVipMapper;
|
|
|
@Autowired
|
|
|
private PersonService personService;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private InviteMessageService inviteMessageService;
|
|
|
+ @Autowired
|
|
|
+ private AssoPersonVipService assoPersonVipService;
|
|
|
/**
|
|
|
* 手机号/账号登录
|
|
|
*
|
|
@@ -90,6 +93,7 @@ public class LoginService {
|
|
|
*/
|
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
|
|
|
public LoginVO loginByPhone(LoginDTO dto) throws Exception {
|
|
|
+ String inviteCode =dto.getInviteCode();
|
|
|
//获取缓存中验证码
|
|
|
Object codeObj = redisService.get(AppCacheKeyUtil.getLoginMessageCode(dto.getPhoneNum()));
|
|
|
if (ToolUtil.isEmpty(codeObj)) {
|
|
@@ -114,12 +118,14 @@ public class LoginService {
|
|
|
Person person = personMapper.selectOne(queryWrapper);
|
|
|
LoginVO loginVO = new LoginVO();
|
|
|
if (ToolUtil.isEmpty(person)) {
|
|
|
+ inviteMessageService.checkInvite(inviteCode);
|
|
|
person = new Person();
|
|
|
person.setPhoneNum(dto.getPhoneNum());
|
|
|
String uid = IdUtil.simpleUUID();
|
|
|
person.setUuid(uid);
|
|
|
|
|
|
personMapper.insert(person);
|
|
|
+ inviteMessageService.addInviteMessage(inviteCode, person.getUuid());
|
|
|
|
|
|
loginVO.setId(person.getId());
|
|
|
loginVO.setPhone(person.getPhoneNum());
|
|
@@ -146,10 +152,13 @@ public class LoginService {
|
|
|
* @date: 2024/04/01
|
|
|
* @return: LoginByWxVO
|
|
|
*/
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public LoginByWxVO loginByWeChat(LoginByWxDTO wxDTO) throws Exception {
|
|
|
+
|
|
|
String code = wxDTO.getCode();
|
|
|
String encryptedData = wxDTO.getEncryptedData();
|
|
|
String iv = wxDTO.getIv();
|
|
|
+ String inviteCode = wxDTO.getInviteCode();
|
|
|
|
|
|
//返回数据
|
|
|
LoginByWxVO wxVO = new LoginByWxVO();
|
|
@@ -180,6 +189,7 @@ public class LoginService {
|
|
|
person.setOpenId(jscode2SessionWo.getOpenid());
|
|
|
person.updateById();
|
|
|
} else {
|
|
|
+ inviteMessageService.checkInvite(inviteCode);
|
|
|
person = new Person();
|
|
|
person.setPhoneNum(phoneNumber);
|
|
|
person.setOpenId(jscode2SessionWo.getOpenid());
|
|
@@ -188,9 +198,11 @@ public class LoginService {
|
|
|
person.insert();
|
|
|
wxVO.setId(person.getId());
|
|
|
wxVO.setIfFirst(true);
|
|
|
+ inviteMessageService.addInviteMessage(inviteCode, person.getUuid());
|
|
|
}
|
|
|
wxVO.setPhoneNum(phoneNumber);
|
|
|
}
|
|
|
+
|
|
|
wxVO.setToken(jwtTokenUtil.createToken());
|
|
|
wxVO.setOpenId(jscode2SessionWo.getOpenid());
|
|
|
// redisService.set(AppCacheKeyUtil.getUserIdToken(wxVO.getId()), AppCacheKeyUtil.getTokenUserInfo(wxVO.getToken()));
|
|
@@ -428,13 +440,13 @@ public class LoginService {
|
|
|
.or().eq(Person::getEmail, account);
|
|
|
Person person = personService.getOne(queryWrapper, false);
|
|
|
if (person == null) {
|
|
|
- throw new BusinessException("606", "账号错误");
|
|
|
+ throw new BusinessException(ExceptionEnum.LOGIN_ACCOUNT_MISTAKE, "账号错误");
|
|
|
}
|
|
|
if (person.getUserPassword() == null) {
|
|
|
- throw new BusinessException("606", "非账号登录用户");
|
|
|
+ throw new BusinessException(ExceptionEnum.LOGIN_PASWORD_MISTAKE, "非账号登录用户");
|
|
|
}
|
|
|
if (!person.getUserPassword().equals(password)) {
|
|
|
- throw new BusinessException("606", "密码错误");
|
|
|
+ throw new BusinessException(ExceptionEnum.LOGIN_PASWORD_MISTAKE, "密码错误");
|
|
|
}
|
|
|
|
|
|
//将用户信息数据存入Redis
|
|
@@ -445,7 +457,7 @@ public class LoginService {
|
|
|
token = jwtTokenUtil.createToken();
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
- throw new BusinessException("606", "生成token错误");
|
|
|
+ throw new BusinessException(ExceptionEnum.LOGIN_ERROR, "生成token错误");
|
|
|
}
|
|
|
BeanUtil.copy(person, loginVO);
|
|
|
loginVO.setToken(token);
|