发送动态礼物新增区域限制

This commit is contained in:
tianfeng 2026-02-04 15:37:27 +08:00
parent 8526bff19a
commit ed7789adda
2 changed files with 23 additions and 1 deletions

View File

@ -38,7 +38,13 @@ public enum GiftErrorCode implements IResponseErrorCode {
/**
* 配置数据未改动.
*/
GAME_LUCKY_GIFT_PROBABILITY_CONFIG_UPDATE_ERROR(8405,"Configuration data unchanged");
GAME_LUCKY_GIFT_PROBABILITY_CONFIG_UPDATE_ERROR(8405,"Configuration data unchanged"),
/**
* 不是同一个大区
*/
NOT_SAME_REGION(8406, "Not the same region"),
;
private final int code;
private final String message;

View File

@ -12,6 +12,7 @@ import com.red.circle.other.app.convertor.material.GiftAppConvertor;
import com.red.circle.other.app.dto.cmd.gift.GiveAwayGiftBatchCmd;
import com.red.circle.other.app.service.task.TaskService;
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway;
import com.red.circle.other.infra.database.cache.service.other.GiftCacheService;
import com.red.circle.other.inner.asserts.GiftErrorCode;
import com.red.circle.other.inner.enums.material.GiftCurrencyType;
@ -30,6 +31,7 @@ import com.red.circle.wallet.inner.model.dto.WalletReceiptResDTO;
import com.red.circle.wallet.inner.model.enums.GoldOrigin;
import java.math.BigDecimal;
import java.util.Objects;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@ -52,6 +54,7 @@ public class GiftGiveAwayBatchCmdExe {
private final UserProfileGateway userProfileGateway;
private final WalletDiamondClient walletDiamondClient;
private final TaskService taskService;
private final UserRegionGateway userRegionGateway;
public BigDecimal execute(GiveAwayGiftBatchCmd cmd) {
@ -69,6 +72,9 @@ public class GiftGiveAwayBatchCmdExe {
ResponseAssert.isTrue(ResponseErrorCode.REQUEST_PARAMETER_ERROR,
CollectionUtils.isNotEmpty(cmd.filterAcceptUserId()));
// 动态礼物检查区域
checkDynamicRegion(cmd);
if (giftConfig.getGiftCandy().equals(new BigDecimal("0.00"))) {
BigDecimal dollarAmount = walletGoldClient.getBalance(cmd.requiredReqUserId()).getBody().getDollarAmount();
log.info("赠送普通礼物金额为0,余额为 {}", dollarAmount);
@ -94,6 +100,16 @@ public class GiftGiveAwayBatchCmdExe {
return receipt.getBalance();
}
private void checkDynamicRegion(GiveAwayGiftBatchCmd cmd) {
if (cmd.getDynamicContentId() == null) {
return;
}
ResponseAssert.isTrue(CommonErrorCode.DATA_ERROR, cmd.getAcceptUserIds() != null && cmd.getAcceptUserIds().size() == 1);
Long acceptUserId = cmd.getAcceptUserIds().get(0);
ResponseAssert.isTrue(GiftErrorCode.NOT_SAME_REGION, userRegionGateway.checkEqRegion(cmd.getReqUserId(), acceptUserId));
}
/**
* 付钱.
*/