用户列表新增首充金额字段
This commit is contained in:
parent
7966cd8166
commit
2a981246ed
@ -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;
|
||||
|
||||
/**
|
||||
* 首充结束时间
|
||||
*/
|
||||
|
||||
@ -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<UserInviteUser> allInvites = userInviteUserDAO.selectList(
|
||||
new LambdaQueryWrapper<UserInviteUser>()
|
||||
.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());
|
||||
|
||||
@ -21,4 +21,9 @@ public interface InviteUserGateway {
|
||||
RechargeCommissionResult getRechargeCommission(BigDecimal rechargeAmount, String sysOrigin,
|
||||
Long inviteUserId);
|
||||
|
||||
/**
|
||||
* 通过被邀请人获取邀请人用户ID
|
||||
*/
|
||||
Long getUserByInviteUserId(Long inviteUserId);
|
||||
|
||||
}
|
||||
|
||||
@ -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<UserInviteUser> allInvites = userInviteUserDAO.selectList(
|
||||
new LambdaQueryWrapper<UserInviteUser>()
|
||||
.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));
|
||||
}
|
||||
|
||||
@ -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<UserInviteUser> allInvites = userInviteUserDAO.selectList(
|
||||
new LambdaQueryWrapper<UserInviteUser>()
|
||||
.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)));
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user