From fb745f89fc68af20524e01995118caf585d4d000 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Fri, 19 Sep 2025 14:26:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B9=B8=E8=BF=90=E7=A4=BC=E7=89=A9=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/common/gift/GameLuckyGiftCommon.java | 27 ++---- .../infra/config/LuckyGiftApiConfig.java | 91 +++++++++++++++++++ .../user/device/ArchiveDeviceService.java | 1 + 3 files changed, 99 insertions(+), 20 deletions(-) create mode 100644 rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/config/LuckyGiftApiConfig.java diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/common/gift/GameLuckyGiftCommon.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/common/gift/GameLuckyGiftCommon.java index 820d7744..9ea5661f 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/common/gift/GameLuckyGiftCommon.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/common/gift/GameLuckyGiftCommon.java @@ -24,6 +24,7 @@ import com.red.circle.other.app.convertor.user.UserProfileAppConvertor; import com.red.circle.other.app.dto.clientobject.game.GameLuckyGiftMsgCO; import com.red.circle.other.app.dto.cmd.gift.GiveAwayGiftBatchCmd; import com.red.circle.other.domain.gateway.user.UserProfileGateway; +import com.red.circle.other.infra.config.LuckyGiftApiConfig; import com.red.circle.other.infra.database.cache.entity.game.luckgift.GameLuckyGiftConfigCache; import com.red.circle.other.infra.database.cache.entity.game.luckgift.GameLuckyGiftInventoryCache; import com.red.circle.other.infra.database.cache.entity.game.luckgift.LuckyGiftInventoryTemplateCache; @@ -94,22 +95,8 @@ public class GameLuckyGiftCommon { private final LuckyGiftProbabilityService luckyGiftProbabilityService; private final GameLuckyGiftRuleConfigService gameLuckyGiftRuleConfigService; private final LuckyGiftProbabilityDetailsService luckyGiftProbabilityDetailsService; + private final LuckyGiftApiConfig luckyGiftApiConfig; - // 第三方幸运礼物API配置 - @Value("${lucky.gift.api.url:https://game-cn-test.jieyou.shop/lucky_gift/start_game}") - private String luckyGiftApiUrl; - - @Value("${lucky.gift.api.app_key:w0GoEN4hg6GEjaYeB6mSG6VHld0LhdqT}") - private String luckyGiftApiAppKey; - - @Value("${lucky.gift.api.app_id:9291621826}") - private String luckyGiftApiAppId; - - @Value("${lucky.gift.api.app_channel:likei}") - private String luckyGiftApiAppChannel; - - @Value("${lucky.gift.api.enabled:true}") - private boolean luckyGiftApiEnabled; /** * 发送幸运礼物抽奖mq. @@ -682,8 +669,8 @@ public class GameLuckyGiftCommon { requestData.put("room_id", param.getRoomId().toString()); requestData.put("user_id", param.getUserId().toString()); requestData.put("order_id", orderIds); - requestData.put("app_id", luckyGiftApiAppId); - requestData.put("app_channel", luckyGiftApiAppChannel); + requestData.put("app_id", luckyGiftApiConfig.getAppId()); + requestData.put("app_channel", luckyGiftApiConfig.getAppChannel()); requestData.put("gift_id", param.getGiftId().intValue()); requestData.put("gift_price", param.getGift().getGiftCandy().intValue()); requestData.put("gift_num", param.getQuantity()); @@ -702,7 +689,7 @@ public class GameLuckyGiftCommon { // 发送HTTP请求 - 使用Hutool的HttpUtil String requestBody = JSON.toJSONString(requestData); - String response = HttpUtil.createPost(luckyGiftApiUrl) + String response = HttpUtil.createPost(luckyGiftApiConfig.getUrl()) .header("Content-Type", "application/json") .header("Accept", "application/json") .timeout(10000) @@ -789,7 +776,7 @@ public class GameLuckyGiftCommon { signBuilder.append(key).append("=").append(valueStr); } } - signBuilder.append("&app_key=").append(luckyGiftApiAppKey); + signBuilder.append("&app_key=").append(luckyGiftApiConfig.getAppKey()); log.debug("签名原始字符串: {}", signBuilder.toString()); @@ -878,7 +865,7 @@ public class GameLuckyGiftCommon { List listInventory, GameLuckyGiftParam param) { // 如果启用第三方API,则调用第三方接口 - if (luckyGiftApiEnabled) { + if (luckyGiftApiConfig.isEnabled()) { return drawLuckyGiftWithThirdPartyApi(listInventory, param); } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/config/LuckyGiftApiConfig.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/config/LuckyGiftApiConfig.java new file mode 100644 index 00000000..bdc8420a --- /dev/null +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/config/LuckyGiftApiConfig.java @@ -0,0 +1,91 @@ +package com.red.circle.other.infra.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.cloud.context.config.annotation.RefreshScope; +import org.springframework.stereotype.Component; + +/** + * 第三方幸运礼物API配置 + */ +@Component +@ConfigurationProperties(prefix = "lucky.gift.api") +@RefreshScope +public class LuckyGiftApiConfig { + + /** + * API地址 + */ + private String url; + + /** + * 应用密钥 + */ + private String appKey; + + /** + * 应用ID + */ + private String appId; + + /** + * 应用渠道 + */ + private String appChannel; + + /** + * 是否启用 + */ + private boolean enabled = true; + + // Getter 和 Setter 方法 + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getAppKey() { + return appKey; + } + + public void setAppKey(String appKey) { + this.appKey = appKey; + } + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getAppChannel() { + return appChannel; + } + + public void setAppChannel(String appChannel) { + this.appChannel = appChannel; + } + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + @Override + public String toString() { + return "LuckyGiftApiConfig{" + + "url='" + url + '\'' + + ", appKey='" + "***" + '\'' + // 敏感信息脱敏 + ", appId='" + appId + '\'' + + ", appChannel='" + appChannel + '\'' + + ", enabled=" + enabled + + '}'; + } +} \ No newline at end of file diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/device/ArchiveDeviceService.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/device/ArchiveDeviceService.java index 2083ddcd..85993886 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/device/ArchiveDeviceService.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/device/ArchiveDeviceService.java @@ -6,6 +6,7 @@ import com.red.circle.other.infra.database.rds.entity.user.user.ArchiveDevice; import com.red.circle.other.inner.model.cmd.user.device.ArchiveDeviceQryCmd; import java.util.Set; + /** *

* 封禁设备 服务类.