From 4c9acce3d6285c4e593bfe395491a353b9c22b94 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Tue, 28 Oct 2025 20:50:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=B8=B8=E6=88=8F=E4=B8=AD?= =?UTF-8?q?=E5=A5=96=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../enums/message/OfficialNoticeTypeEnum.java | 7 ++- .../service/game/GameBaishunServiceImpl.java | 43 ++++++++++++++++++- .../service/sys/GameListConfigService.java | 5 +++ .../sys/impl/GameListConfigServiceImpl.java | 12 ++++++ 4 files changed, 64 insertions(+), 3 deletions(-) diff --git a/rc-service/rc-inner-api/external-inner/external-inner-model/src/main/java/com/red/circle/external/inner/model/enums/message/OfficialNoticeTypeEnum.java b/rc-service/rc-inner-api/external-inner/external-inner-model/src/main/java/com/red/circle/external/inner/model/enums/message/OfficialNoticeTypeEnum.java index 0aed1c5b..4f86474b 100644 --- a/rc-service/rc-inner-api/external-inner/external-inner-model/src/main/java/com/red/circle/external/inner/model/enums/message/OfficialNoticeTypeEnum.java +++ b/rc-service/rc-inner-api/external-inner/external-inner-model/src/main/java/com/red/circle/external/inner/model/enums/message/OfficialNoticeTypeEnum.java @@ -195,7 +195,12 @@ public enum OfficialNoticeTypeEnum { /** * 用户关注 */ - USER_FOLLOW + USER_FOLLOW, + + /** + * 百顺游戏中奖 + */ + GAME_BAISHUN_WIN, ; diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/game/GameBaishunServiceImpl.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/game/GameBaishunServiceImpl.java index 0a88cef8..0e37c835 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/game/GameBaishunServiceImpl.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/game/GameBaishunServiceImpl.java @@ -13,6 +13,9 @@ import com.red.circle.component.game.baishun.response.BaishunResponse; import com.red.circle.component.game.baishun.response.BaishunTokenResponse; import com.red.circle.component.game.baishun.response.BaishunUserProfileResponse; import com.red.circle.component.redis.service.RedisService; +import com.red.circle.external.inner.endpoint.message.OfficialNoticeClient; +import com.red.circle.external.inner.model.cmd.message.notice.official.NoticeExtTemplateTypeCmd; +import com.red.circle.external.inner.model.enums.message.OfficialNoticeTypeEnum; import com.red.circle.framework.core.asserts.ResponseAssert; import com.red.circle.framework.core.exception.ResponseException; import com.red.circle.framework.core.security.UserCredential; @@ -20,7 +23,13 @@ import com.red.circle.mq.business.model.event.game.GameBaiShunTwoFunProperties; import com.red.circle.mq.business.model.event.task.TaskApprovalEvent; import com.red.circle.mq.rocket.business.producer.TaskMqMessage; import com.red.circle.other.app.convertor.user.UserProfileAppConvertor; +import com.red.circle.other.app.util.OfficialNoticeUtils; import com.red.circle.other.domain.gateway.user.UserProfileGateway; +import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheService; +import com.red.circle.other.infra.database.cache.service.other.GameListCacheService; +import com.red.circle.other.infra.database.rds.entity.sys.GameListConfig; +import com.red.circle.other.infra.database.rds.service.sys.GameListConfigService; +import com.red.circle.other.inner.enums.config.EnumConfigKey; import com.red.circle.other.inner.model.dto.user.UserProfileDTO; import com.red.circle.tool.core.date.DateUtils; import com.red.circle.tool.core.date.LocalDateTimeUtils; @@ -32,6 +41,7 @@ import com.red.circle.wallet.inner.model.cmd.GoldReceiptCmd.GoldReceiptCmdBuilde 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.Map; import java.util.Objects; import java.util.concurrent.TimeUnit; import lombok.RequiredArgsConstructor; @@ -54,8 +64,10 @@ public class GameBaishunServiceImpl implements GameBaishunService { private final UserProfileGateway userProfileGateway; private final GameBaishunProperties gameBaishunProperties; private final TaskMqMessage taskMqMessage; - private final GameBaiShunTwoFunProperties gameBaiShunTwoFunProperties; + private final OfficialNoticeClient officialNoticeClient; private final UserProfileAppConvertor userProfileAppConvertor; + private final EnumConfigCacheService enumConfigCacheService; + private final GameListConfigService gameListConfigService; @Override public BaishunResponse getToken(BaishunTokenRequest request) { @@ -148,6 +160,8 @@ public class GameBaishunServiceImpl implements GameBaishunService { WalletReceiptResDTO receiptRes = walletGoldClient.changeBalance(createReceipt(request)) .getBody(); + String sysOrigin = UserCredential.parseToken(request.getToken()).getSysOrigin(); + //游玩一句游戏结束 每日任务 baishun Long userId = DataTypeUtils.toLong(request.getUserId()); taskMqMessage.sendTask(TaskApprovalEvent.builder() @@ -155,10 +169,35 @@ public class GameBaishunServiceImpl implements GameBaishunService { .userId(userId) .day(LocalDateTimeUtils.nowFormat("yyyy-MM-dd")) .currencyDiff(request.getCurrencyDiff()) - .sysOrigin(UserCredential.parseToken(request.getToken()).getSysOrigin()) + .sysOrigin(sysOrigin) .gameName(GoldOrigin.BAISHUN_GAME.name()) .gameId(Long.parseLong(request.getGameId())) .build()); + + BigDecimal cost = enumConfigCacheService + .getValueBigDecimal(EnumConfigKey.HIGH_VALUE_GIFT_STANDARD, sysOrigin); + if (cost.compareTo(BigDecimal.ZERO) <= 0) { + cost = BigDecimal.valueOf(5000L); + } + + if (request.getCurrencyDiff() >= cost.longValue()) { + UserProfileDTO userProfile = userProfileAppConvertor.toUserProfileDTO( + userProfileGateway.getByUserId(DataTypeUtils.toLong(request.getUserId()))); + + GameListConfig gameListConfig = gameListConfigService.getByGameId(request.getGameId(), sysOrigin); + if (Objects.nonNull(gameListConfig)) { + Map build = OfficialNoticeUtils.buildUserProfile(userProfile); + build.put("gameUrl", gameListConfig.getCover()); + build.put("currencyDiff", request.getCurrencyDiff()); + officialNoticeClient.send(NoticeExtTemplateTypeCmd.builder() + .toAccount(userId) + .noticeType(OfficialNoticeTypeEnum.GAME_BAISHUN_WIN) + .templateParam(build) + .build() + ); + } + } + log.warn("{} 发送游戏获奖通知--金币数量{}", GoldOrigin.BAISHUN_GAME.name(), request.getCurrencyDiff()); return BaishunResponse.success(new BaishunChangeCurrencyResponse() .setCurrencyBalance(receiptRes.getBalance().getDollarAmount().stripTrailingZeros()), diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/sys/GameListConfigService.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/sys/GameListConfigService.java index 465c803f..80c4a0ed 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/sys/GameListConfigService.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/sys/GameListConfigService.java @@ -42,6 +42,11 @@ public interface GameListConfigService extends BaseService { */ GameListConfig getByGameCode(String gameCode, String sysOrigin); + /** + * 查询游戏信息 + */ + GameListConfig getByGameId(String gameId, String sysOrigin); + /** * 校验是否有游戏下架 */ diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/sys/impl/GameListConfigServiceImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/sys/impl/GameListConfigServiceImpl.java index c1c6e2d9..3f18b938 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/sys/impl/GameListConfigServiceImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/sys/impl/GameListConfigServiceImpl.java @@ -115,6 +115,18 @@ public class GameListConfigServiceImpl extends .getOne(); } + /** + * @param gameId 1345 + */ + @Override + public GameListConfig getByGameId(String gameId, String sysOrigin) { + return query() + .likeRight(GameListConfig::getName, "_" + gameId) // 匹配 %_1345 + .eq(GameListConfig::getSysOrigin, sysOrigin) + .last(PageConstant.LIMIT_ONE) + .getOne(); + } + @Override public Boolean checkGameUnshelve(Set gameIds) { return Optional.ofNullable(query()