release: 新手欢迎奖励积分任务

release-2024-08-08
huangyw 4 months ago
parent 0a39ea0975
commit e8b51a5dbe

@ -0,0 +1,51 @@
package constants;
/**
* @program: luoo_parent
* @description: id
* @author: yawei.huang
* @create: 2024-07-24 15:50
**/
public class TaskPointIdConstants {
// 新手欢迎奖励 todo
public static final String NEW_USER_WELCOME_AWARD = "1";
// 修改头像 todo
public static final String MODIFY_AVATAR = "2";
// 修改昵称 todo
public static final String MODIFY_NICKNAME = "3";
// 完善个人信息 todo
public static final String COMPLETE_PERSONAL_INFORMATION = "4";
// 成功关注1位用户 todo
public static final String SUCCESS_FOLLOW_ONE_USER = "5";
// 首次分享期刊 todo
public static final String FIRST_SHARE_JOURNAL = "6";
// 首次收藏期刊 todo
public static final String FIRST_COLLECT_JOURNAL = "7";
// 首次购物成功 todo
public static final String FIRST_SHOPPING_SUCCESS = "8";
// 首次完成评价 todo
public static final String FIRST_COMPLETE_COMMENT = "9";
// 开通会员 todo
public static final String OPEN_MEMBER = "10";
// 以下不需要校验是否已做过
// 每日登录 todo
public static final String DAILY_LOGIN = "11";
// 每日签到 todo
public static final String DAILY_SIGN = "12";
// 分享期刊 todo
public static final String SHARE_JOURNAL = "13";
// 邀请好友 todo
public static final String INVITE_FRIEND = "14";
// 好友首次下单成功 todo
public static final String FRIEND_FIRST_ORDER_SUCCESS = "15";
// 购买天数达标 todo
public static final String BUY_DAYS_REACHED = "16";
// 积分抽奖 todo
public static final String POINT_LOTTERY = "17";
// 积分商城 todo
public static final String POINT_SHOP = "18";
}

@ -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());
}

Loading…
Cancel
Save