|
|
@ -18,6 +18,7 @@ import com.luoo.user.util.NickNameUtil;
|
|
|
|
import com.luoo.user.util.NickNameUtil2;
|
|
|
|
import com.luoo.user.util.NickNameUtil2;
|
|
|
|
import constants.Constants;
|
|
|
|
import constants.Constants;
|
|
|
|
import constants.ErrorConstants;
|
|
|
|
import constants.ErrorConstants;
|
|
|
|
|
|
|
|
import constants.TaskPointIdConstants;
|
|
|
|
import dto.UserLoginDto;
|
|
|
|
import dto.UserLoginDto;
|
|
|
|
import enums.UserBankStateEnum;
|
|
|
|
import enums.UserBankStateEnum;
|
|
|
|
import enums.UserRealNameStateEnum;
|
|
|
|
import enums.UserRealNameStateEnum;
|
|
|
@ -55,34 +56,44 @@ import java.util.stream.Collectors;
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
|
public class UserInfoService {
|
|
|
|
public class UserInfoService {
|
|
|
|
@Autowired
|
|
|
|
private final UserInfoDao userInfoDao;
|
|
|
|
private UserInfoDao userInfoDao;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private IdWorker idWorker;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private final IdWorker idWorker;
|
|
|
|
private RedisTemplate redisTemplate;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private final RedisTemplate redisTemplate;
|
|
|
|
private RabbitTemplate rabbitTemplate;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private final RabbitTemplate rabbitTemplate;
|
|
|
|
private BCryptPasswordEncoder encoder;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private final BCryptPasswordEncoder encoder;
|
|
|
|
private HttpServletRequest request;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private final HttpServletRequest request;
|
|
|
|
private JwtUtil jwtUtil;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private final JwtUtil jwtUtil;
|
|
|
|
private UserRealNameDao userRealNameDao;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private final UserRealNameDao userRealNameDao;
|
|
|
|
private UserBankDao userBankDao;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private final UserBankDao userBankDao;
|
|
|
|
private WithdrawDao withdrawDao;
|
|
|
|
|
|
|
|
|
|
|
|
private final WithdrawDao withdrawDao;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final UserPointLogService userPointLogService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public UserInfoService(UserInfoDao userInfoDao, IdWorker idWorker, RedisTemplate redisTemplate,
|
|
|
|
|
|
|
|
RabbitTemplate rabbitTemplate, BCryptPasswordEncoder encoder, HttpServletRequest request,
|
|
|
|
|
|
|
|
JwtUtil jwtUtil, UserRealNameDao userRealNameDao, UserBankDao userBankDao,
|
|
|
|
|
|
|
|
WithdrawDao withdrawDao, UserPointLogService userPointLogService) {
|
|
|
|
|
|
|
|
this.userInfoDao = userInfoDao;
|
|
|
|
|
|
|
|
this.idWorker = idWorker;
|
|
|
|
|
|
|
|
this.redisTemplate = redisTemplate;
|
|
|
|
|
|
|
|
this.rabbitTemplate = rabbitTemplate;
|
|
|
|
|
|
|
|
this.encoder = encoder;
|
|
|
|
|
|
|
|
this.request = request;
|
|
|
|
|
|
|
|
this.jwtUtil = jwtUtil;
|
|
|
|
|
|
|
|
this.userRealNameDao = userRealNameDao;
|
|
|
|
|
|
|
|
this.userBankDao = userBankDao;
|
|
|
|
|
|
|
|
this.withdrawDao = withdrawDao;
|
|
|
|
|
|
|
|
this.userPointLogService = userPointLogService;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* token解析示例
|
|
|
|
* token解析示例
|
|
|
@ -215,6 +226,7 @@ public class UserInfoService {
|
|
|
|
|
|
|
|
|
|
|
|
public String loginOrRegister(UserInfo loginUserInfo) {
|
|
|
|
public String loginOrRegister(UserInfo loginUserInfo) {
|
|
|
|
UserInfo userInfo = userInfoDao.findByMobile(loginUserInfo.getMobile());
|
|
|
|
UserInfo userInfo = userInfoDao.findByMobile(loginUserInfo.getMobile());
|
|
|
|
|
|
|
|
boolean isNewUser = false;
|
|
|
|
if (null == userInfo) {
|
|
|
|
if (null == userInfo) {
|
|
|
|
userInfo = loginUserInfo;
|
|
|
|
userInfo = loginUserInfo;
|
|
|
|
userInfo.setId(String.valueOf(idWorker.nextId()));
|
|
|
|
userInfo.setId(String.valueOf(idWorker.nextId()));
|
|
|
@ -228,6 +240,7 @@ public class UserInfoService {
|
|
|
|
userInfo.setThumbnail(Constants.DEFAULT_USER_THUMBNAIL);
|
|
|
|
userInfo.setThumbnail(Constants.DEFAULT_USER_THUMBNAIL);
|
|
|
|
userInfo.setSignature(Constants.DEFAULT_USER_SIGNATURE);
|
|
|
|
userInfo.setSignature(Constants.DEFAULT_USER_SIGNATURE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isNewUser = true;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// userInfo.setAppleId(loginUserInfo.getAppleId());
|
|
|
|
// userInfo.setAppleId(loginUserInfo.getAppleId());
|
|
|
|
userInfo.setLastUseDeviceId(loginUserInfo.getLastUseDeviceId());
|
|
|
|
userInfo.setLastUseDeviceId(loginUserInfo.getLastUseDeviceId());
|
|
|
@ -239,6 +252,12 @@ public class UserInfoService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
userInfo.setLastLoginTime(new Date());
|
|
|
|
userInfo.setLastLoginTime(new Date());
|
|
|
|
userInfoDao.save(userInfo);
|
|
|
|
userInfoDao.save(userInfo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(isNewUser) {
|
|
|
|
|
|
|
|
// 只有新用户会获得积分
|
|
|
|
|
|
|
|
userPointLogService.addByTaskNew(TaskPointIdConstants.NEW_USER_WELCOME_AWARD, userInfo.getId());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return Constants.TOKEN_PREFIX
|
|
|
|
return Constants.TOKEN_PREFIX
|
|
|
|
+ jwtUtil.createJWT(userInfo.getId(), userInfo.getNickName(), Constants.TOKEN_ROLE_APP_USER, userInfo.getAvatar());
|
|
|
|
+ jwtUtil.createJWT(userInfo.getId(), userInfo.getNickName(), Constants.TOKEN_ROLE_APP_USER, userInfo.getAvatar());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -246,6 +265,7 @@ public class UserInfoService {
|
|
|
|
|
|
|
|
|
|
|
|
public String appleLoginOrRegister(UserInfo loginUserInfo) {
|
|
|
|
public String appleLoginOrRegister(UserInfo loginUserInfo) {
|
|
|
|
UserInfo userInfo = userInfoDao.findByAppleId(loginUserInfo.getAppleId());
|
|
|
|
UserInfo userInfo = userInfoDao.findByAppleId(loginUserInfo.getAppleId());
|
|
|
|
|
|
|
|
boolean isNewUser = false;
|
|
|
|
if (null == userInfo) {
|
|
|
|
if (null == userInfo) {
|
|
|
|
// return "未注册";
|
|
|
|
// return "未注册";
|
|
|
|
userInfo = loginUserInfo;
|
|
|
|
userInfo = loginUserInfo;
|
|
|
@ -259,6 +279,8 @@ public class UserInfoService {
|
|
|
|
userInfo.setAvatar(Constants.DEFAULT_USER_AVATAR);
|
|
|
|
userInfo.setAvatar(Constants.DEFAULT_USER_AVATAR);
|
|
|
|
userInfo.setThumbnail(Constants.DEFAULT_USER_THUMBNAIL);
|
|
|
|
userInfo.setThumbnail(Constants.DEFAULT_USER_THUMBNAIL);
|
|
|
|
userInfo.setSignature(Constants.DEFAULT_USER_SIGNATURE);
|
|
|
|
userInfo.setSignature(Constants.DEFAULT_USER_SIGNATURE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isNewUser = true;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
userInfo.setLastUseDeviceId(loginUserInfo.getLastUseDeviceId());
|
|
|
|
userInfo.setLastUseDeviceId(loginUserInfo.getLastUseDeviceId());
|
|
|
|
userInfo.setLastUseDeviceBrand(loginUserInfo.getLastUseDeviceBrand());
|
|
|
|
userInfo.setLastUseDeviceBrand(loginUserInfo.getLastUseDeviceBrand());
|
|
|
@ -269,6 +291,11 @@ public class UserInfoService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
userInfo.setLastLoginTime(new Date());
|
|
|
|
userInfo.setLastLoginTime(new Date());
|
|
|
|
userInfoDao.save(userInfo);
|
|
|
|
userInfoDao.save(userInfo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(isNewUser) {
|
|
|
|
|
|
|
|
// 只有新用户会获得积分
|
|
|
|
|
|
|
|
userPointLogService.addByTaskNew(TaskPointIdConstants.NEW_USER_WELCOME_AWARD, userInfo.getId());
|
|
|
|
|
|
|
|
}
|
|
|
|
return Constants.TOKEN_PREFIX
|
|
|
|
return Constants.TOKEN_PREFIX
|
|
|
|
+ jwtUtil.createJWT(userInfo.getId(), userInfo.getNickName(), Constants.TOKEN_ROLE_APP_USER, userInfo.getAvatar());
|
|
|
|
+ jwtUtil.createJWT(userInfo.getId(), userInfo.getNickName(), Constants.TOKEN_ROLE_APP_USER, userInfo.getAvatar());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -318,6 +345,9 @@ public class UserInfoService {
|
|
|
|
|
|
|
|
|
|
|
|
public String wechatRegister(UserInfo loginUserInfo) {
|
|
|
|
public String wechatRegister(UserInfo loginUserInfo) {
|
|
|
|
UserInfo userInfo = userInfoDao.findByMobile(loginUserInfo.getMobile());
|
|
|
|
UserInfo userInfo = userInfoDao.findByMobile(loginUserInfo.getMobile());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean isNewUser = false;
|
|
|
|
|
|
|
|
|
|
|
|
if (null == userInfo) {
|
|
|
|
if (null == userInfo) {
|
|
|
|
userInfo = loginUserInfo;
|
|
|
|
userInfo = loginUserInfo;
|
|
|
|
userInfo.setId(String.valueOf(idWorker.nextId()));
|
|
|
|
userInfo.setId(String.valueOf(idWorker.nextId()));
|
|
|
@ -330,6 +360,8 @@ public class UserInfoService {
|
|
|
|
userInfo.setAvatar(Constants.DEFAULT_USER_AVATAR);
|
|
|
|
userInfo.setAvatar(Constants.DEFAULT_USER_AVATAR);
|
|
|
|
userInfo.setThumbnail(Constants.DEFAULT_USER_THUMBNAIL);
|
|
|
|
userInfo.setThumbnail(Constants.DEFAULT_USER_THUMBNAIL);
|
|
|
|
userInfo.setSignature(Constants.DEFAULT_USER_SIGNATURE);
|
|
|
|
userInfo.setSignature(Constants.DEFAULT_USER_SIGNATURE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isNewUser = true;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
userInfo.setLastUseDeviceId(loginUserInfo.getLastUseDeviceId());
|
|
|
|
userInfo.setLastUseDeviceId(loginUserInfo.getLastUseDeviceId());
|
|
|
|
userInfo.setLastUseDeviceBrand(loginUserInfo.getLastUseDeviceBrand());
|
|
|
|
userInfo.setLastUseDeviceBrand(loginUserInfo.getLastUseDeviceBrand());
|
|
|
@ -342,6 +374,11 @@ public class UserInfoService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
userInfo.setLastLoginTime(new Date());
|
|
|
|
userInfo.setLastLoginTime(new Date());
|
|
|
|
userInfoDao.save(userInfo);
|
|
|
|
userInfoDao.save(userInfo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(isNewUser) {
|
|
|
|
|
|
|
|
// 只有新用户会获得积分
|
|
|
|
|
|
|
|
userPointLogService.addByTaskNew(TaskPointIdConstants.NEW_USER_WELCOME_AWARD, userInfo.getId());
|
|
|
|
|
|
|
|
}
|
|
|
|
return Constants.TOKEN_PREFIX
|
|
|
|
return Constants.TOKEN_PREFIX
|
|
|
|
+ jwtUtil.createJWT(userInfo.getId(), userInfo.getNickName(), Constants.TOKEN_ROLE_APP_USER, userInfo.getAvatar());
|
|
|
|
+ jwtUtil.createJWT(userInfo.getId(), userInfo.getNickName(), Constants.TOKEN_ROLE_APP_USER, userInfo.getAvatar());
|
|
|
|
}
|
|
|
|
}
|
|
|
|