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