From 2a981246ed0138b4b2a72403950984b0c41bf475 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Fri, 6 Mar 2026 17:21:47 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=88=97=E8=A1=A8=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E9=A6=96=E5=85=85=E9=87=91=E9=A2=9D=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inner/model/dto/user/UserProfileDTO.java | 6 ++++ .../user/query/UserProfileUseQryExe.java | 36 +++++++++++++++---- .../user/ability/InviteUserGateway.java | 5 +++ .../gateway/user/InviteUserGatewayImpl.java | 18 ++++++++++ .../UserRunProfileTransportGatewayImpl.java | 24 +++++++++---- 5 files changed, 76 insertions(+), 13 deletions(-) diff --git a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/dto/user/UserProfileDTO.java b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/dto/user/UserProfileDTO.java index 82b00d8d..8f1eb650 100644 --- a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/dto/user/UserProfileDTO.java +++ b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/dto/user/UserProfileDTO.java @@ -14,6 +14,7 @@ import com.red.circle.other.inner.model.dto.user.props.UserUseBadgeDTO; import com.red.circle.other.inner.model.dto.user.props.UserUsePropsDTO; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.time.LocalDateTime; @@ -241,6 +242,11 @@ public class UserProfileDTO implements Serializable { */ private Boolean firstRecharge; + /** + * 首充金额 + */ + private BigDecimal firstRechargeAmount; + /** * 首充结束时间 */ diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/query/UserProfileUseQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/query/UserProfileUseQryExe.java index 9f2f1a2c..b00894a9 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/query/UserProfileUseQryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/query/UserProfileUseQryExe.java @@ -1,6 +1,6 @@ package com.red.circle.other.app.command.user.query; -import cn.hutool.core.collection.CollectionUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.red.circle.common.business.core.AppBusinessUtils; import com.red.circle.common.business.dto.cmd.app.AppUserIdCmd; import com.red.circle.component.redis.service.RedisService; @@ -9,27 +9,25 @@ import com.red.circle.framework.core.response.CommonErrorCode; import com.red.circle.other.app.convertor.user.UserProfileAppConvertor; import com.red.circle.other.app.dto.clientobject.user.user.UserLevelCO; import com.red.circle.other.app.dto.cmd.user.user.UserProfileQryCmd; -import com.red.circle.other.app.service.room.RoomProfileService; import com.red.circle.other.app.service.user.relation.UserSupportRelationService; import com.red.circle.other.domain.gateway.user.UserProfileGateway; import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway; import com.red.circle.other.domain.model.user.UserProfile; -import com.red.circle.other.infra.database.cache.key.user.UserKey; import com.red.circle.other.infra.database.cache.service.cp.CpRelationshipCacheService; import com.red.circle.other.infra.database.mongo.entity.live.RoomProfileManager; import com.red.circle.other.infra.database.mongo.service.live.RoomProfileManagerService; +import com.red.circle.other.infra.database.rds.dao.user.user.UserInviteUserDAO; import com.red.circle.other.infra.database.rds.entity.family.FamilyMemberInfo; +import com.red.circle.other.infra.database.rds.entity.user.user.UserInviteUser; import com.red.circle.other.infra.database.rds.service.family.FamilyMemberInfoService; import com.red.circle.other.infra.database.rds.service.user.user.CpValueService; -import com.red.circle.other.inner.model.dto.user.CpSimpleUserProfileCO; import com.red.circle.tool.core.text.StringUtils; import com.red.circle.other.inner.asserts.user.UserErrorCode; import com.red.circle.other.inner.model.dto.user.UserProfileDTO; import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.*; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -54,6 +52,9 @@ public class UserProfileUseQryExe { private final CpValueService cpValueService; private final CpRelationshipCacheService cpRelationshipCacheService; private final FamilyMemberInfoService familyMemberInfoService; + private final UserInviteUserDAO userInviteUserDAO; + + private static final String INVITE_RECHARGE_TOTAL_KEY = "invite:recharge:total:%d:%d"; public UserProfileDTO execute(UserProfileQryCmd cmd) { UserProfile userProfile = getUserProfile(cmd); @@ -107,9 +108,32 @@ public class UserProfileUseQryExe { } userProfileDTO.setFamilyId(Optional.ofNullable(familyMemberInfoService.getFamilyMemberByUserId(userProfileDTO.getId())).map(FamilyMemberInfo::getFamilyId).orElse(null)); + userProfileDTO.setFirstRechargeAmount(getFirstRechargeAmount(userProfileDTO)); return userProfileDTO; } + private BigDecimal getFirstRechargeAmount(UserProfileDTO userProfileDTO) { + if (userProfileDTO.getFirstRecharge() == null || !userProfileDTO.getFirstRecharge()) { + return null; + } + + List allInvites = userInviteUserDAO.selectList( + new LambdaQueryWrapper() + .eq(UserInviteUser::getInviteUserId, userProfileDTO.getId()) + .orderByDesc(UserInviteUser::getCreateTime) + ); + if (allInvites == null || allInvites.isEmpty()) { + return null; + } + UserInviteUser userInviteUser = allInvites.get(0); + + String key = String.format(INVITE_RECHARGE_TOTAL_KEY, userInviteUser.getUserId(), userInviteUser.getInviteUserId()); + int quantity = redisService.getStringToInteger(key); + + return BigDecimal.valueOf(quantity) + .divide(BigDecimal.valueOf(10000), 2, RoundingMode.HALF_UP); + } + private UserProfile getUserProfile(UserProfileQryCmd cmd) { if (Objects.nonNull(cmd.getUserId())) { return userProfileGateway.getByUserId(cmd.getUserId()); diff --git a/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/gateway/user/ability/InviteUserGateway.java b/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/gateway/user/ability/InviteUserGateway.java index d641c38e..f7824397 100644 --- a/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/gateway/user/ability/InviteUserGateway.java +++ b/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/gateway/user/ability/InviteUserGateway.java @@ -21,4 +21,9 @@ public interface InviteUserGateway { RechargeCommissionResult getRechargeCommission(BigDecimal rechargeAmount, String sysOrigin, Long inviteUserId); + /** + * 通过被邀请人获取邀请人用户ID + */ + Long getUserByInviteUserId(Long inviteUserId); + } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/InviteUserGatewayImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/InviteUserGatewayImpl.java index aab10149..351051bc 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/InviteUserGatewayImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/InviteUserGatewayImpl.java @@ -201,6 +201,24 @@ public class InviteUserGatewayImpl implements InviteUserGateway { return allInvites.get(0); } + @Override + public Long getUserByInviteUserId(Long inviteUserId) { + if (Objects.isNull(inviteUserId)) { + return null; + } + + List allInvites = userInviteUserDAO.selectList( + new LambdaQueryWrapper() + .eq(UserInviteUser::getInviteUserId, inviteUserId) + .orderByDesc(UserInviteUser::getCreateTime) + ); + if (CollectionUtils.isEmpty(allInvites)) { + return null; + } + + return allInvites.get(0).getUserId(); + } + private Integer getCommissionDays(String sysOrigin) { return userInviteCacheService.getCommissionDays(SysOriginPlatformEnum.valueOf(sysOrigin)); } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/UserRunProfileTransportGatewayImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/UserRunProfileTransportGatewayImpl.java index 1a90c7ea..141df3b8 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/UserRunProfileTransportGatewayImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/UserRunProfileTransportGatewayImpl.java @@ -1,6 +1,7 @@ package com.red.circle.other.infra.gateway.user; import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.red.circle.other.domain.gateway.props.PropsNobleVipGateway; @@ -17,11 +18,13 @@ import com.red.circle.other.infra.database.mongo.entity.user.profile.UserRunProf import com.red.circle.other.infra.database.mongo.entity.user.profile.UserSpecialId; import com.red.circle.other.infra.database.mongo.service.user.profile.UserRunProfileService; import com.red.circle.other.infra.database.mongo.service.user.profile.UserSpecialIdService; +import com.red.circle.other.infra.database.rds.dao.user.user.UserInviteUserDAO; import com.red.circle.other.infra.database.rds.entity.family.FamilyMemberInfo; import com.red.circle.other.infra.database.rds.entity.props.PropsBackpack; import com.red.circle.other.infra.database.rds.entity.user.user.BaseInfo; import com.red.circle.other.infra.database.rds.entity.user.user.OneTimeTask; import com.red.circle.other.infra.database.rds.entity.user.user.CpRelationship; +import com.red.circle.other.infra.database.rds.entity.user.user.UserInviteUser; import com.red.circle.other.infra.database.rds.service.badge.BadgeConfigService; import com.red.circle.other.infra.database.rds.service.badge.BadgePictureConfigService; import com.red.circle.other.infra.database.rds.service.family.FamilyMemberInfoService; @@ -29,10 +32,7 @@ import com.red.circle.other.infra.database.rds.service.props.PropsBackpackServic import com.red.circle.other.infra.database.rds.service.props.PropsSourceRecordService; import com.red.circle.other.infra.database.rds.service.props.RoomThemeUserBackpackService; import com.red.circle.other.infra.database.rds.service.props.RoomThemeUserCustomizeService; -import com.red.circle.other.infra.database.rds.service.user.user.BaseInfoService; -import com.red.circle.other.infra.database.rds.service.user.user.OneTimeTaskService; -import com.red.circle.other.infra.database.rds.service.user.user.CpRelationshipService; -import com.red.circle.other.infra.database.rds.service.user.user.CpValueService; +import com.red.circle.other.infra.database.rds.service.user.user.*; import com.red.circle.other.infra.utils.ZonedDateTimeUtils; import com.red.circle.other.inner.enums.material.BadgeBackpackExpireType; import com.red.circle.other.inner.enums.material.BadgeConfigTypeEnum; @@ -95,10 +95,11 @@ public class UserRunProfileTransportGatewayImpl implements UserRunProfileTranspo private final RoomThemeUserCustomizeService roomThemeUserCustomizeService; private final OneTimeTaskService oneTimeTaskService; private final FamilyMemberInfoService familyMemberInfoService; + private final UserInviteUserDAO userInviteUserDAO; @Override public UserProfile getByUserId(Long userId) { - UserRunProfile userRunProfile = userRunProfileService.getById(userId); + UserRunProfile userRunProfile = null; if (Objects.nonNull(userRunProfile)) { // 拥有靓号 UserSpecialId userSpecialId = userSpecialIdService.getByUserId(userId); @@ -312,8 +313,17 @@ public class UserRunProfileTransportGatewayImpl implements UserRunProfileTranspo LocalDateTime createTime = newUserRunProfile.getCreateTime().toLocalDateTime(); Duration duration = Duration.between(createTime, LocalDateTime.now()); if (duration.toDays() < 7) { - OneTimeTask response = oneTimeTaskService.queryCompletedFirstCharge(newUserRunProfile.getId(), newUserRunProfile.getOriginSys()); - if (response == null) { + List allInvites = userInviteUserDAO.selectList( + new LambdaQueryWrapper() + .eq(UserInviteUser::getInviteUserId, newUserRunProfile.getId()) + .orderByDesc(UserInviteUser::getCreateTime) + ); + if (allInvites == null || allInvites.isEmpty()) { + return; + } + + UserInviteUser userInviteUser = allInvites.get(0); + if (userInviteUser != null) { newUserRunProfile.setFirstRecharge(true); newUserRunProfile.setFirstRechargeEndTime(ZonedDateTimeUtils.toTimestampDefault(createTime.plusDays(7))); }