|
|
@@ -10,6 +10,7 @@ import com.xuekairui.invite.entity.*;
|
|
|
import com.xuekairui.invite.mapper.InviteCodeMapper;
|
|
|
import com.xuekairui.invite.mapper.InviteRelationMapper;
|
|
|
import com.xuekairui.user.dto.CrawlerPlatformStatsResponse;
|
|
|
+import com.xuekairui.user.dto.CrawlerQuotaGrantResponse;
|
|
|
import com.xuekairui.user.dto.CrawlerUserDetailResponse;
|
|
|
import com.xuekairui.user.entity.CrawlerPlatform;
|
|
|
import com.xuekairui.user.entity.CrawlerQuotaGrant;
|
|
|
@@ -719,8 +720,20 @@ public class InviteService {
|
|
|
*/
|
|
|
@Transactional
|
|
|
public CrawlerQuotaGrant adminGrantQuota(QuotaGrantRequest request) {
|
|
|
+ Long userId = request.getUserId();
|
|
|
+ if (userId == null && request.getPhone() != null && !request.getPhone().isBlank()) {
|
|
|
+ User u = userMapper.selectOne(
|
|
|
+ new LambdaQueryWrapper<User>().eq(User::getPhone, request.getPhone()));
|
|
|
+ if (u == null) {
|
|
|
+ throw new BusinessException(ErrorCode.USER_NOT_FOUND);
|
|
|
+ }
|
|
|
+ userId = u.getId();
|
|
|
+ }
|
|
|
+ if (userId == null) {
|
|
|
+ throw new BusinessException(ErrorCode.PARAM_ERROR, "用户ID和手机号至少填写一个");
|
|
|
+ }
|
|
|
return crawlerQuotaGrantService.grantAdminQuota(
|
|
|
- request.getUserId(),
|
|
|
+ userId,
|
|
|
request.getQuotaCount(),
|
|
|
request.getExpireTime(),
|
|
|
request.getRemark());
|
|
|
@@ -834,20 +847,19 @@ public class InviteService {
|
|
|
|
|
|
List<InviteRelation> relations = result.getRecords();
|
|
|
if (relations.isEmpty()) {
|
|
|
- Page<InviteRewardResponse> empty = new Page<>(pageNum, pageSize, 0);
|
|
|
- return empty;
|
|
|
+ return new Page<>(pageNum, pageSize, 0);
|
|
|
}
|
|
|
|
|
|
// 批量查被邀请人和邀请码
|
|
|
List<Long> inviteeIds = relations.stream()
|
|
|
.map(InviteRelation::getInviteeId).distinct().toList();
|
|
|
- Map<Long, User> userMap = userMapper.selectBatchIds(inviteeIds).stream()
|
|
|
+ Map<Long, User> userMap = userMapper.selectByIds(inviteeIds).stream()
|
|
|
.collect(Collectors.toMap(User::getId, u -> u));
|
|
|
|
|
|
List<Long> codeIds = relations.stream()
|
|
|
- .map(InviteRelation::getInviteCodeId).filter(id -> id != null).distinct().toList();
|
|
|
+ .map(InviteRelation::getInviteCodeId).filter(Objects::nonNull).distinct().toList();
|
|
|
Map<Long, String> codeMap = codeIds.isEmpty() ? Map.of()
|
|
|
- : inviteCodeMapper.selectBatchIds(codeIds).stream()
|
|
|
+ : inviteCodeMapper.selectByIds(codeIds).stream()
|
|
|
.collect(Collectors.toMap(InviteCode::getId, InviteCode::getCode));
|
|
|
|
|
|
// 邀请人信息只查一次
|
|
|
@@ -929,7 +941,7 @@ public class InviteService {
|
|
|
/**
|
|
|
* 获取发放记录列表
|
|
|
*/
|
|
|
- public Page<com.xuekairui.user.dto.CrawlerQuotaGrantResponse> listGrants(Long userId, String grantType,
|
|
|
+ public Page<CrawlerQuotaGrantResponse> listGrants(Long userId, String grantType,
|
|
|
int page, int size) {
|
|
|
return crawlerQuotaGrantService.listGrants(userId, grantType, page, size);
|
|
|
}
|
|
|
@@ -1078,7 +1090,14 @@ public class InviteService {
|
|
|
/**
|
|
|
* 获取用户爬虫使用详情(含平台分布统计)
|
|
|
*/
|
|
|
- public CrawlerUserDetailResponse getCrawlerUserDetail(Long userId) {
|
|
|
+ public CrawlerUserDetailResponse getCrawlerUserDetail(Long userId, String phone) {
|
|
|
+ if (userId == null && phone != null && !phone.isBlank()) {
|
|
|
+ User u = userMapper.selectOne(
|
|
|
+ new LambdaQueryWrapper<User>().eq(User::getPhone, phone));
|
|
|
+ if (u == null) throw new BusinessException(ErrorCode.USER_NOT_FOUND);
|
|
|
+ userId = u.getId();
|
|
|
+ }
|
|
|
+ if (userId == null) throw new BusinessException(ErrorCode.PARAM_ERROR, "用户ID和手机号至少填写一个");
|
|
|
User user = userMapper.selectById(userId);
|
|
|
if (user == null) {
|
|
|
throw new BusinessException(ErrorCode.USER_NOT_FOUND);
|
|
|
@@ -1154,7 +1173,18 @@ public class InviteService {
|
|
|
/**
|
|
|
* 获取用户邀请转化统计(点击-注册转化率)
|
|
|
*/
|
|
|
- public InviteConversionStatsResponse getInviteConversionStats(Long userId) {
|
|
|
+ public InviteConversionStatsResponse getInviteConversionStats(Long userId, String phone) {
|
|
|
+ if (userId == null && phone != null && !phone.isBlank()) {
|
|
|
+ User u = userMapper.selectOne(
|
|
|
+ new LambdaQueryWrapper<User>().eq(User::getPhone, phone));
|
|
|
+ if (u == null) {
|
|
|
+ throw new BusinessException(ErrorCode.USER_NOT_FOUND);
|
|
|
+ }
|
|
|
+ userId = u.getId();
|
|
|
+ }
|
|
|
+ if (userId == null) {
|
|
|
+ throw new BusinessException(ErrorCode.PARAM_ERROR, "用户ID和手机号至少填写一个");
|
|
|
+ }
|
|
|
// 获取用户邀请码
|
|
|
InviteCodeResponse codeResponse = getOrCreateInviteCode(userId);
|
|
|
|