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

Loading…
Cancel
Save