Jelajahi Sumber

fix : 腾讯媒体sdk测试修改2002

bilingfeng 4 bulan lalu
induk
melakukan
214e8f96c3

+ 1 - 1
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/SDKApplication.java

@@ -23,7 +23,7 @@ public class SDKApplication {
 
     public static void main(String[] args) {
         SpringApplication.run(SDKApplication.class, args);
-        System.out.println("赞象SDK服务启动成功 <腾讯媒体sdk测试修改300> ( ´・・)ノ(._.`) \n" +
+        System.out.println("赞象SDK服务启动成功 <腾讯媒体sdk测试修改2002> ( ´・・)ノ(._.`) \n" +
                 " ___________ _   __\n" +
                 "/  ___|  _  \\ | / /\n" +
                 "\\ `--.| | | | |/ / \n" +

+ 27 - 12
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/GameServiceImpl.java

@@ -46,24 +46,39 @@ public class GameServiceImpl extends ServiceImpl<GameMapper, Game> implements IG
         if (Objects.equals(game.getCategory(), GameCategoryEnum.CATEGORY_APP.getId())) {
             return JsonUtil.toMap(game.getAdSdkConfig(), Map.class, Object.class);
         }
-        //微信小游戏, 根据归属渠道, 判断当前是投的腾讯还是头条
-        if (Objects.equals(game.getCategory(), GameCategoryEnum.CATEGORY_WX_APPLET.getId())) {
-            //当前调试阶段
-            if (Objects.equals(game.getStatus(), 2)) {
+        //不是微信小程序, 不返回配置
+        if (!Objects.equals(game.getCategory(), GameCategoryEnum.CATEGORY_WX_APPLET.getId())) {
+            //默认返回不初始化
+            return Collections.singletonMap("adSdk", 0);
+        }
+        //目前只有投腾讯才返回
+        Agent agent = this.getUserAgent(userData.getUserId());
+        if (agent != null) {
+            //腾讯广告
+            if (Objects.equals(agent.getAccountType(), AccountTypeEnum.TENCENT_MINI_GAME.getValue())) {
                 return JsonUtil.toMap(game.getAdSdkConfig(), Map.class, Object.class);
             }
-            //不存在userId, 无法判断在投的是腾讯还是头条, 不返回配置
-            if (userData.getUserId() == null) {
+            //头条广告
+            if (Objects.equals(agent.getAccountType(), AccountTypeEnum.BYTE.getValue())) {
                 return Collections.singletonMap("adSdk", 0);
             }
-            //非调试阶段, 目前只有投腾讯才返回,
-            User user = userService.getById(userData.getUserId());
-            Agent agent = agentService.getById(user.getAgentId());
-            if (agent != null && Objects.equals(agent.getAccountType(), AccountTypeEnum.TENCENT_MINI_GAME.getValue())) {
-                return JsonUtil.toMap(game.getAdSdkConfig(), Map.class, Object.class);
-            }
+        }
+        //当前调试阶段
+        if (userData.getUserId() != null && Objects.equals(game.getStatus(), 2)) {
+            return JsonUtil.toMap(game.getAdSdkConfig(), Map.class, Object.class);
         }
         //默认返回不初始化
         return Collections.singletonMap("adSdk", 0);
     }
+
+    private Agent getUserAgent(Long userId) {
+        if (userId == null) {
+            return null;
+        }
+        User user = userService.getById(userId);
+        if (user == null) {
+            return null;
+        }
+        return agentService.getById(user.getAgentId());
+    }
 }