diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/common/room/RoomRegionFilterCommon.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/common/room/RoomRegionFilterCommon.java index 46715811..71077356 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/common/room/RoomRegionFilterCommon.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/common/room/RoomRegionFilterCommon.java @@ -23,8 +23,11 @@ import org.springframework.stereotype.Service; @RequiredArgsConstructor public class RoomRegionFilterCommon { - // account 1001041 - private static final Set ALL_REGION_ROOM_WHITELIST_USER_IDS = Set.of(2044700023064686594L); + // account 1001041, 1001545 + private static final Set ALL_REGION_ROOM_WHITELIST_USER_IDS = Set.of( + 2044700023064686594L, + 2047206645188063233L + ); private final UserRegionGateway userRegionGateway; diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/game/BaishunRuntimeConfigResolver.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/game/BaishunRuntimeConfigResolver.java index fe5b4605..d583b92c 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/game/BaishunRuntimeConfigResolver.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/game/BaishunRuntimeConfigResolver.java @@ -19,6 +19,7 @@ import org.springframework.stereotype.Component; public class BaishunRuntimeConfigResolver { private static final String DEFAULT_SYS_ORIGIN = SysOriginPlatformEnum.LIKEI.name(); + private static final String LUCKY_GIFT_START_GAME_PATH = "/lucky_gift/start_game"; private final BaishunProviderConfigService baishunProviderConfigService; private final GameBaishunProperties gameBaishunProperties; @@ -51,7 +52,7 @@ public class BaishunRuntimeConfigResolver { ApiAccount resolved = new ApiAccount(); resolved.setStandardId(base.getStandardId()); - resolved.setUrl(base.getUrl()); + resolved.setUrl(defaultIfBlank(resolveLuckyGiftApiUrl(config.getPlatformBaseUrl()), base.getUrl())); resolved.setAppId(defaultIfBlank(config.getAppId(), base.getAppId())); resolved.setAppChannel(defaultIfBlank(config.getAppChannel(), base.getAppChannel())); resolved.setAppKey(defaultIfBlank(config.getAppKey(), base.getAppKey())); @@ -83,6 +84,26 @@ public class BaishunRuntimeConfigResolver { .build(); } + private String resolveLuckyGiftApiUrl(String platformBaseUrl) { + String baseUrl = trim(platformBaseUrl); + if (StringUtils.isBlank(baseUrl)) { + return null; + } + String normalized = trimTrailingSlash(baseUrl); + if (normalized.endsWith(LUCKY_GIFT_START_GAME_PATH)) { + return normalized; + } + return normalized + LUCKY_GIFT_START_GAME_PATH; + } + + private String trimTrailingSlash(String value) { + String result = trim(value); + while (StringUtils.isNotBlank(result) && result.endsWith("/")) { + result = result.substring(0, result.length() - 1); + } + return result; + } + private String normalizeSysOrigin(String sysOrigin) { return StringUtils.isBlank(sysOrigin) ? DEFAULT_SYS_ORIGIN : sysOrigin.trim(); } diff --git a/rc-service/rc-service-other/other-application/src/test/java/com/red/circle/other/app/service/game/BaishunRuntimeConfigResolverTest.java b/rc-service/rc-service-other/other-application/src/test/java/com/red/circle/other/app/service/game/BaishunRuntimeConfigResolverTest.java new file mode 100644 index 00000000..aabfe8c7 --- /dev/null +++ b/rc-service/rc-service-other/other-application/src/test/java/com/red/circle/other/app/service/game/BaishunRuntimeConfigResolverTest.java @@ -0,0 +1,50 @@ +package com.red.circle.other.app.service.game; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import com.red.circle.component.game.baishun.props.GameBaishunProperties; +import com.red.circle.other.infra.config.LuckyGiftApiConfig; +import com.red.circle.other.infra.config.LuckyGiftApiConfig.ApiAccount; +import com.red.circle.other.infra.database.rds.entity.game.BaishunProviderConfig; +import com.red.circle.other.infra.database.rds.service.game.BaishunProviderConfigService; +import org.junit.jupiter.api.Test; + +class BaishunRuntimeConfigResolverTest { + + @Test + void resolveLuckyGiftApiAccountUsesActiveBaishunProviderConfig() { + BaishunProviderConfigService providerConfigService = mock(BaishunProviderConfigService.class); + GameBaishunProperties gameBaishunProperties = mock(GameBaishunProperties.class); + LuckyGiftApiConfig luckyGiftApiConfig = mock(LuckyGiftApiConfig.class); + BaishunRuntimeConfigResolver resolver = new BaishunRuntimeConfigResolver( + providerConfigService, + gameBaishunProperties, + luckyGiftApiConfig + ); + + ApiAccount fallback = new ApiAccount(); + fallback.setStandardId(99L); + fallback.setUrl("https://legacy.example.com/lucky_gift/start_game"); + fallback.setAppId("legacy-app"); + fallback.setAppChannel("legacy-channel"); + fallback.setAppKey("legacy-key"); + when(luckyGiftApiConfig.getConfigByStandardId(99L)).thenReturn(fallback); + + when(providerConfigService.getBySysOrigin("LIKEI")).thenReturn(new BaishunProviderConfig() + .setSysOrigin("LIKEI") + .setPlatformBaseUrl("https://provider.example.com/") + .setAppId(4581045902L) + .setAppChannel("yumiparty") + .setAppKey("provider-key")); + + ApiAccount resolved = resolver.resolveLuckyGiftApiAccount("LIKEI", 99L); + + assertEquals(99L, resolved.getStandardId()); + assertEquals("https://provider.example.com/lucky_gift/start_game", resolved.getUrl()); + assertEquals("4581045902", resolved.getAppId()); + assertEquals("yumiparty", resolved.getAppChannel()); + assertEquals("provider-key", resolved.getAppKey()); + } +}