每日任务逻辑优化

This commit is contained in:
tianfeng 2025-12-16 12:31:09 +08:00
parent 21258dee1b
commit c077c563eb
4 changed files with 49 additions and 25 deletions

View File

@ -10,6 +10,7 @@ import com.red.circle.mq.rocket.business.producer.GiftMqMessage;
import com.red.circle.mq.rocket.business.producer.TaskMqMessage; import com.red.circle.mq.rocket.business.producer.TaskMqMessage;
import com.red.circle.other.app.convertor.material.GiftAppConvertor; 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.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.UserProfileGateway;
import com.red.circle.other.infra.database.cache.service.other.GiftCacheService; 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.asserts.GiftErrorCode;
@ -50,6 +51,7 @@ public class GiftGiveAwayBatchCmdExe {
private final TaskMqMessage taskMqMessage; private final TaskMqMessage taskMqMessage;
private final UserProfileGateway userProfileGateway; private final UserProfileGateway userProfileGateway;
private final WalletDiamondClient walletDiamondClient; private final WalletDiamondClient walletDiamondClient;
private final TaskService taskService;
public BigDecimal execute(GiveAwayGiftBatchCmd cmd) { public BigDecimal execute(GiveAwayGiftBatchCmd cmd) {
@ -79,12 +81,16 @@ public class GiftGiveAwayBatchCmdExe {
giftMqMessage.sendGift(receipt.getConsumeId().toString(), giftMqMessage.sendGift(receipt.getConsumeId().toString(),
giftAppConvertor.toGiveAwayGiftBatchEvent(cmd, giftConfig, receipt.getConsumeId())); giftAppConvertor.toGiveAwayGiftBatchEvent(cmd, giftConfig, receipt.getConsumeId()));
userProfileGateway.removeCache(cmd.requiredReqUserId()); userProfileGateway.removeCache(cmd.requiredReqUserId());
taskMqMessage.sendTask(TaskApprovalEvent.builder()
.taskId(2)
.userId(cmd.getReqUserId())
.day(LocalDateTimeUtils.nowFormat("yyyy-MM-dd"))
.build());
// 检查是否未完成任务
Boolean taskStatus = taskService.checkTaskStatus(cmd.getReqUserId(), 2L, LocalDateTimeUtils.nowFormat("yyyy-MM-dd"));
if (taskStatus) {
taskMqMessage.sendTask(TaskApprovalEvent.builder()
.taskId(2)
.userId(cmd.getReqUserId())
.day(LocalDateTimeUtils.nowFormat("yyyy-MM-dd"))
.build());
}
return receipt.getBalance(); return receipt.getBalance();
} }

View File

@ -9,6 +9,7 @@ import com.red.circle.mq.rocket.business.producer.TaskMqMessage;
import com.red.circle.other.app.common.gift.GameLuckyGiftCommon; import com.red.circle.other.app.common.gift.GameLuckyGiftCommon;
import com.red.circle.other.app.convertor.material.GiftAppConvertor; 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.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.UserProfileGateway;
import com.red.circle.other.infra.database.cache.service.other.GiftCacheService; 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.asserts.GiftErrorCode;
@ -45,6 +46,7 @@ public class LuckyGiftGiveCmdExe {
private final UserProfileGateway userProfileGateway; private final UserProfileGateway userProfileGateway;
private final GameLuckyGiftCommon gameLuckyGiftCommon; private final GameLuckyGiftCommon gameLuckyGiftCommon;
private final TaskMqMessage taskMqMessage; private final TaskMqMessage taskMqMessage;
private final TaskService taskService;
public BigDecimal execute(GiveAwayGiftBatchCmd cmd) { public BigDecimal execute(GiveAwayGiftBatchCmd cmd) {
@ -79,11 +81,15 @@ public class LuckyGiftGiveCmdExe {
userProfileGateway.removeCache(cmd.requiredReqUserId()); userProfileGateway.removeCache(cmd.requiredReqUserId());
taskMqMessage.sendTask(TaskApprovalEvent.builder() // 检查是否未完成任务
.taskId(8) Boolean taskStatus = taskService.checkTaskStatus(cmd.getReqUserId(), 8L, null);
.quantity(cmd.getQuantity()) if (taskStatus) {
.userId(cmd.getReqUserId()) taskMqMessage.sendTask(TaskApprovalEvent.builder()
.build()); .taskId(8)
.quantity(cmd.getQuantity())
.userId(cmd.getReqUserId())
.build());
}
return receipt.getBalance().getDollarAmount(); return receipt.getBalance().getDollarAmount();
} }

View File

@ -6,6 +6,7 @@ import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.mq.business.model.event.task.TaskApprovalEvent; import com.red.circle.mq.business.model.event.task.TaskApprovalEvent;
import com.red.circle.mq.rocket.business.producer.TaskMqMessage; import com.red.circle.mq.rocket.business.producer.TaskMqMessage;
import com.red.circle.other.app.dto.clientobject.team.TeamMemberWorkDailyTargetCO; import com.red.circle.other.app.dto.clientobject.team.TeamMemberWorkDailyTargetCO;
import com.red.circle.other.app.service.task.TaskService;
import com.red.circle.other.infra.common.team.TeamTargetCommon; import com.red.circle.other.infra.common.team.TeamTargetCommon;
import com.red.circle.other.infra.database.mongo.entity.live.RoomProfile; import com.red.circle.other.infra.database.mongo.entity.live.RoomProfile;
import com.red.circle.other.infra.database.mongo.entity.team.team.TeamMemberTarget; import com.red.circle.other.infra.database.mongo.entity.team.team.TeamMemberTarget;
@ -46,14 +47,19 @@ public class TeamMemberHeartbeatCmdExe {
private final TeamMemberTargetService teamMemberTargetService; private final TeamMemberTargetService teamMemberTargetService;
private final TaskMqMessage taskMqMessage; private final TaskMqMessage taskMqMessage;
private final AdministratorService administratorService; private final AdministratorService administratorService;
private final TaskService taskService;
public void execute(AppRoomIdCmd cmd) { public void execute(AppRoomIdCmd cmd) {
//心跳mic 每日任务
taskMqMessage.sendTask(TaskApprovalEvent.builder() Boolean taskStatus = taskService.checkTaskStatus(cmd.requiredReqUserId(), 1L, LocalDateTimeUtils.nowFormat("yyyy-MM-dd"));
.taskId(1) if (taskStatus) {
.userId(cmd.requiredReqUserId()) //心跳mic 每日任务
.day(LocalDateTimeUtils.nowFormat("yyyy-MM-dd")) taskMqMessage.sendTask(TaskApprovalEvent.builder()
.build()); .taskId(1)
.userId(cmd.requiredReqUserId())
.day(LocalDateTimeUtils.nowFormat("yyyy-MM-dd"))
.build());
}
boolean admin = administratorService.existsAdmin(cmd.requiredReqUserId()); boolean admin = administratorService.existsAdmin(cmd.requiredReqUserId());
if (admin) { if (admin) {

View File

@ -27,6 +27,7 @@ import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
import com.red.circle.other.app.dto.cmd.activity.RankingDataUpdateCmd; import com.red.circle.other.app.dto.cmd.activity.RankingDataUpdateCmd;
import com.red.circle.other.app.enums.violation.GameOriginEnum; import com.red.circle.other.app.enums.violation.GameOriginEnum;
import com.red.circle.other.app.service.activity.RankingActivityService; import com.red.circle.other.app.service.activity.RankingActivityService;
import com.red.circle.other.app.service.task.TaskService;
import com.red.circle.other.app.util.OfficialNoticeUtils; import com.red.circle.other.app.util.OfficialNoticeUtils;
import com.red.circle.other.domain.game.GameRankingIncrementCmd; import com.red.circle.other.domain.game.GameRankingIncrementCmd;
import com.red.circle.other.domain.gateway.game.GameRankingGateway; import com.red.circle.other.domain.gateway.game.GameRankingGateway;
@ -81,6 +82,7 @@ public class GameBaishunServiceImpl implements GameBaishunService {
private final RankingActivityService rankingActivityService; private final RankingActivityService rankingActivityService;
private final GameRankingGateway gameRankingGateway; private final GameRankingGateway gameRankingGateway;
private final GameListCacheService gameListCacheService; private final GameListCacheService gameListCacheService;
private final TaskService taskService;
@Value("${red-circle.game-rank.gameid}") @Value("${red-circle.game-rank.gameid}")
private String gameId; private String gameId;
@ -179,15 +181,19 @@ public class GameBaishunServiceImpl implements GameBaishunService {
//游玩一句游戏结束 每日任务 baishun //游玩一句游戏结束 每日任务 baishun
Long userId = DataTypeUtils.toLong(request.getUserId()); Long userId = DataTypeUtils.toLong(request.getUserId());
taskMqMessage.sendTask(TaskApprovalEvent.builder() // 检查是否未完成任务
.taskId(4) Boolean taskStatus = taskService.checkTaskStatus(userId, 4L, LocalDateTimeUtils.nowFormat("yyyy-MM-dd"));
.userId(userId) if (taskStatus) {
.day(LocalDateTimeUtils.nowFormat("yyyy-MM-dd")) taskMqMessage.sendTask(TaskApprovalEvent.builder()
.currencyDiff(request.getCurrencyDiff()) .taskId(4)
.sysOrigin(sysOrigin) .userId(userId)
.gameName(GoldOrigin.BAISHUN_GAME.name()) .day(LocalDateTimeUtils.nowFormat("yyyy-MM-dd"))
.gameId(Long.parseLong(request.getGameId())) .currencyDiff(request.getCurrencyDiff())
.build()); .sysOrigin(sysOrigin)
.gameName(GoldOrigin.BAISHUN_GAME.name())
.gameId(Long.parseLong(request.getGameId()))
.build());
}
GameListConfig gameListConfig = gameListCacheService.getByGameIdWithCache( GameListConfig gameListConfig = gameListCacheService.getByGameIdWithCache(
request.getGameId(), request.getGameId(),