用户发送红包新增限制财富等级10级

This commit is contained in:
tianfeng 2026-01-14 15:03:56 +08:00
parent 7f2910f598
commit 69ada2534f
2 changed files with 15 additions and 0 deletions

View File

@ -168,6 +168,10 @@ public enum OtherErrorCode implements IResponseErrorCode {
NOT_RED_PACKET_RECEIVER(40302, "You are not a red envelope recipient"),
/**
* 用户财富等级不足10级
*/
USER_WEALTH_NEED_THAN_10(40303, "User wealth level needs to be greater than 10"),
;
private final int code;

View File

@ -1,5 +1,7 @@
package com.red.circle.other.app.command.redpacket;
import com.red.circle.common.business.core.enums.SysOriginPlatformEnum;
import com.red.circle.common.business.core.level.LevelUtils;
import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.other.app.convertor.UserRedPacketAppConvertor;
import com.red.circle.other.app.dto.clientobject.UserRedPacketCO;
@ -9,6 +11,8 @@ import com.red.circle.other.domain.redpacket.RoomRedPacketType;
import com.red.circle.other.domain.redpacket.UserRedPacket;
import com.red.circle.other.domain.redpacket.UserRedPacketStatus;
import com.red.circle.other.infra.database.cache.service.other.UserRedPacketCacheService;
import com.red.circle.other.infra.database.rds.entity.user.user.ConsumptionLevel;
import com.red.circle.other.infra.database.rds.service.user.user.ConsumptionLevelService;
import com.red.circle.other.inner.asserts.OtherErrorCode;
import com.red.circle.tool.core.sequence.IdWorkerUtils;
import com.red.circle.tool.core.tuple.PennyAmount;
@ -21,6 +25,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.HashMap;
@ -37,6 +42,7 @@ public class SendUserRedPacketCmdExe {
private final UserRedPacketGateway userRedPacketGateway;
private final UserRedPacketCacheService userRedPacketCacheService;
private final WalletGoldClient walletGoldClient;
private final ConsumptionLevelService consumptionLevelService;
/**
* 手续费比例10%
@ -85,6 +91,11 @@ public class SendUserRedPacketCmdExe {
if (cmd.getTotalAmount() < 100 || cmd.getTotalAmount() > 50000) {
throw new RuntimeException(OtherErrorCode.RED_PACKET_AMOUNT_ERROR.getMessage());
}
ConsumptionLevel consumptionLevel = consumptionLevelService.getByUserId(cmd.getReqUserId());
Integer level = LevelUtils.getWealthLevel(SysOriginPlatformEnum.LIKEI, consumptionLevel.getConsumptionGolds().longValue()).getLevel();
ResponseAssert.isTrue(OtherErrorCode.USER_WEALTH_NEED_THAN_10, level >= 10);
}
/**