release: 新用户邀请获得积分

release-2024-08-08
huangyw 4 months ago
parent f98edf5119
commit c6ef77b8de

@ -109,6 +109,13 @@ public class MyController extends BaseController {
userRespDTO.setEnableComment(user.getEnableComment()); userRespDTO.setEnableComment(user.getEnableComment());
userRespDTO.setPoint(user.getPoint()); userRespDTO.setPoint(user.getPoint());
String invitationUserId = user.getInvitationUserId();
if(StringUtils.isNotEmpty(invitationUserId)) {
UserInfo myInvitationUser = userInfoService.findById(invitationUserId);
userRespDTO.setInvitationUserId(myInvitationUser.getId());
userRespDTO.setInvitationCode(myInvitationUser.getInvitationCode());
}
if (null != user.getEnableNotice()) { if (null != user.getEnableNotice()) {
userRespDTO.setEnableNotice(user.getEnableNotice()); userRespDTO.setEnableNotice(user.getEnableNotice());
} }
@ -150,6 +157,11 @@ public class MyController extends BaseController {
// 修改了性别 // 修改了性别
boolean isChangeSex = !Objects.equals(userInfoUpdateDto.getSex(), user.getSex()); boolean isChangeSex = !Objects.equals(userInfoUpdateDto.getSex(), user.getSex());
if(StringUtils.isNotBlank(userInfoUpdateDto.getInvitationCode()) && StringUtils.isBlank(user.getInvitationUserId())) {
// 只有没有被邀请过的才会触发,再次修改无效
userInfoService.bindInvitationCode(user, userInfoUpdateDto.getInvitationCode());
}
if (!StringTools.isEmpty(nickName)) { if (!StringTools.isEmpty(nickName)) {
user.setNickName(nickName); user.setNickName(nickName);
rabbitTemplate.convertAndSend("userInfoCommentCache", userLoginDto.getUserId()); rabbitTemplate.convertAndSend("userInfoCommentCache", userLoginDto.getUserId());

@ -16,4 +16,7 @@ public class UserInfoUpdateDto {
private String signature; private String signature;
@ApiModelProperty(value = "生日,格式为: yyyy.MM.dd") @ApiModelProperty(value = "生日,格式为: yyyy.MM.dd")
private String birthDay; private String birthDay;
@ApiModelProperty(value = "邀请码,填写的邀请码,不是本人的邀请码")
private String invitationCode;
} }

@ -32,6 +32,4 @@ public class LoginReq implements Serializable {
@ApiModelProperty(name = "deviceBrand", value = "设备品牌", required = false) @ApiModelProperty(name = "deviceBrand", value = "设备品牌", required = false)
String deviceBrand; String deviceBrand;
@ApiModelProperty(name = "invitationCode", value = "邀请码", required = false)
String invitationCode;
} }

@ -104,4 +104,19 @@ public class UserRespDTO implements Serializable {
* *
*/ */
private Integer point; private Integer point;
/**
*
*/
private String invitationCode;
/**
*
*/
private String invitationUserId;
/**
*
*/
private String myInvitationCode;
} }

@ -7,6 +7,7 @@ import com.luoo.user.dao.UserInfoDao;
import com.luoo.user.dao.UserPointLogDao; import com.luoo.user.dao.UserPointLogDao;
import com.luoo.user.dao.UserRealNameDao; import com.luoo.user.dao.UserRealNameDao;
import com.luoo.user.dao.WithdrawDao; import com.luoo.user.dao.WithdrawDao;
import com.luoo.user.dto.UserInfoUpdateDto;
import com.luoo.user.dto.UserQueryReq; import com.luoo.user.dto.UserQueryReq;
import com.luoo.user.dto.UserRealNameCheckDto; import com.luoo.user.dto.UserRealNameCheckDto;
import com.luoo.user.dto.UserRealNameFormDto; import com.luoo.user.dto.UserRealNameFormDto;
@ -270,17 +271,30 @@ public class UserInfoService {
if(isNewUser) { if(isNewUser) {
// 只有新用户会获得积分 // 只有新用户会获得积分
userPointLogService.addByTaskNew(TaskPointIdConstants.NEW_USER_WELCOME_AWARD, userInfo.getId()); userPointLogService.addByTaskNew(TaskPointIdConstants.NEW_USER_WELCOME_AWARD, userInfo.getId());
}
if(StringUtils.isNotBlank(loginReq.getInvitationCode())) { return Constants.TOKEN_PREFIX
// 新用户,且存在邀请码 + jwtUtil.createJWT(userInfo.getId(), userInfo.getNickName(), Constants.TOKEN_ROLE_APP_USER, userInfo.getAvatar());
UserInfo userInfoDaoByInvitationCode = userInfoDao.findByInvitationCode(loginReq.getInvitationCode()); }
if(null != userInfoDaoByInvitationCode) {
userInfo.setInvitationUserId(userInfoDaoByInvitationCode.getId());
userInfo.setInvitationCode(userInfoDaoByInvitationCode.getInvitationCode());
userInfoDao.save(userInfo);
// 邀请码有效,且新用户,则给邀请人积分 /**
userPointLogService.addByTaskNew(TaskPointIdConstants.NEW_USER_INVITE, userInfoDaoByInvitationCode.getId()); *
*
* @param userInfo
* @param invitationCode
*/
@Transactional(rollbackFor = Exception.class)
public void bindInvitationCode(UserInfo userInfo, String invitationCode) {
if (StringUtils.isNotBlank(invitationCode)) {
UserInfo userInfoDaoByInvitationCode = userInfoDao.findByInvitationCode(invitationCode);
if (null != userInfoDaoByInvitationCode) {
// 设置邀请人
userInfo.setInvitationUserId(userInfoDaoByInvitationCode.getId());
this.update(userInfo);
// 邀请人与被邀请人同时获取积分
userPointLogService.addByTaskDailyAndUserId(TaskPointIdConstants.NEW_USER_INVITE, userInfoDaoByInvitationCode.getId());
userPointLogService.addByTaskDailyAndUserId(TaskPointIdConstants.NEW_USER_INVITE, userInfo.getId());
}
List<UserPointLog> list = userPointLogDao.findUserPointLogsByUserIdAndTaskPointId(userInfoDaoByInvitationCode.getId(), TaskPointIdConstants.NEW_USER_INVITE); List<UserPointLog> list = userPointLogDao.findUserPointLogsByUserIdAndTaskPointId(userInfoDaoByInvitationCode.getId(), TaskPointIdConstants.NEW_USER_INVITE);
if (list.size() == 3) { if (list.size() == 3) {
@ -292,12 +306,8 @@ public class UserInfoService {
} else if (list.size() == 20) { } else if (list.size() == 20) {
userPointLogService.addByTaskDailyAndUserId(TaskPointIdConstants.INVITE_USER_20, userInfoDaoByInvitationCode.getId()); userPointLogService.addByTaskDailyAndUserId(TaskPointIdConstants.INVITE_USER_20, userInfoDaoByInvitationCode.getId());
} }
}
}
}
return Constants.TOKEN_PREFIX }
+ jwtUtil.createJWT(userInfo.getId(), userInfo.getNickName(), Constants.TOKEN_ROLE_APP_USER, userInfo.getAvatar());
} }
public String loginOrRegister(UserInfo loginUserInfo) { public String loginOrRegister(UserInfo loginUserInfo) {

Loading…
Cancel
Save