添加邀请进度
This commit is contained in:
@@ -11,6 +11,12 @@ import lombok.Data;
|
||||
public class InviteStatsDto {
|
||||
/** 累计邀请人数 */
|
||||
private Long inviteCount;
|
||||
/** 当前周期已邀请人数 */
|
||||
private Long milestoneProgress;
|
||||
/** 累计获得会员天数 */
|
||||
private Integer rewardDays;
|
||||
/** 里程碑目标人数 */
|
||||
private Integer milestoneTarget;
|
||||
/** 里程碑奖励天数 */
|
||||
private Integer milestoneDays;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.jiayunet.tool.UserSecurityTool;
|
||||
import org.jiayunet.tool.server.RedisServerTool;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -42,6 +43,12 @@ public class UserManageService {
|
||||
@Autowired
|
||||
private RedisServerTool redisServerTool;
|
||||
|
||||
@Value("${app.reward.invite-milestone-count:30}")
|
||||
private int inviteMilestoneCount;
|
||||
|
||||
@Value("${app.reward.invite-milestone-days:150}")
|
||||
private int inviteMilestoneDays;
|
||||
|
||||
/**
|
||||
* 查看个人信息
|
||||
* <p>根据当前登录用户ID查询用户基本信息</p>
|
||||
@@ -99,9 +106,12 @@ public class UserManageService {
|
||||
List<UserInvite> invites = userInviteMapper.selectList(new LambdaQueryWrapper<UserInvite>().eq(UserInvite::getInviterId, userId));
|
||||
|
||||
InviteStatsDto dto = new InviteStatsDto();
|
||||
|
||||
dto.setInviteCount((long) invites.size());
|
||||
long total = invites.size();
|
||||
dto.setInviteCount(total);
|
||||
dto.setMilestoneProgress(total % inviteMilestoneCount);
|
||||
dto.setRewardDays(invites.stream().mapToInt(i -> i.getRewardDays() == null ? 0 : i.getRewardDays()).sum());
|
||||
dto.setMilestoneTarget(inviteMilestoneCount);
|
||||
dto.setMilestoneDays(inviteMilestoneDays);
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +61,12 @@ public class UserRegisterService {
|
||||
@Value("${app.reward.invite-days:7}")
|
||||
private int inviteDays;
|
||||
|
||||
@Value("${app.reward.invite-milestone-count:30}")
|
||||
private int inviteMilestoneCount;
|
||||
|
||||
@Value("${app.reward.invite-milestone-days:150}")
|
||||
private int inviteMilestoneDays;
|
||||
|
||||
/**
|
||||
* 注册新用户
|
||||
* <p>1. 创建用户并生成邀请码 2. 若携带邀请码则绑定邀请关系</p>
|
||||
@@ -123,6 +129,15 @@ public class UserRegisterService {
|
||||
// 发放邀请人会员权益
|
||||
memberGrantService.grant(inviter.getId(), inviteDays, 2); // 2=试用
|
||||
messageService.sendToUser(1, inviter.getId(), "邀请奖励到账", "您邀请的好友已成功注册," + inviteDays + "天会员权益已到账", null, null);
|
||||
|
||||
// 里程碑奖励:每满N人额外发放
|
||||
long totalInvited = userInviteMapper.selectCount(new LambdaQueryWrapper<UserInvite>().eq(UserInvite::getInviterId, inviter.getId()));
|
||||
if (totalInvited > 0 && totalInvited % inviteMilestoneCount == 0) {
|
||||
memberGrantService.grant(inviter.getId(), inviteMilestoneDays, 2);
|
||||
messageService.sendToUser(1, inviter.getId(), "里程碑奖励到账",
|
||||
"恭喜您累计邀请满" + totalInvited + "位好友,额外赠送" + inviteMilestoneDays + "天会员权益!", null, null);
|
||||
log.info("邀请里程碑奖励 inviterId:{} totalInvited:{} days:{}", inviter.getId(), totalInvited, inviteMilestoneDays);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -93,6 +93,9 @@ app:
|
||||
register-days: 3
|
||||
# 邀请好友奖励会员天数
|
||||
invite-days: 7
|
||||
# 邀请里程碑:每满N人额外奖励
|
||||
invite-milestone-count: 30
|
||||
invite-milestone-days: 150
|
||||
|
||||
# AI 多供应商配置,第一个为默认 provider
|
||||
# base-url 配到版本路径,如 DeepSeek: https://api.deepseek.com/v1,豆包: https://ark.cn-beijing.volces.com/api/v3
|
||||
|
||||
@@ -93,6 +93,9 @@ app:
|
||||
register-days: 3
|
||||
# 邀请好友奖励会员天数
|
||||
invite-days: 7
|
||||
# 邀请里程碑:每满N人额外奖励
|
||||
invite-milestone-count: 30
|
||||
invite-milestone-days: 150
|
||||
|
||||
# AI 多供应商配置,第一个为默认 provider
|
||||
# base-url 配到版本路径,如 DeepSeek: https://api.deepseek.com/v1,豆包: https://ark.cn-beijing.volces.com/api/v3
|
||||
|
||||
@@ -94,6 +94,9 @@ app:
|
||||
register-days: 3
|
||||
# 邀请好友奖励会员天数
|
||||
invite-days: 7
|
||||
# 邀请里程碑:每满N人额外奖励
|
||||
invite-milestone-count: 30
|
||||
invite-milestone-days: 150
|
||||
|
||||
# AI 多供应商配置,第一个为默认 provider
|
||||
# base-url 配到版本路径,如 DeepSeek: https://api.deepseek.com/v1,豆包: https://ark.cn-beijing.volces.com/api/v3
|
||||
|
||||
Reference in New Issue
Block a user