Prechádzať zdrojové kódy

fix : 创角回传, 新增角色等级参数

bilingfeng 8 mesiacov pred
rodič
commit
739992de2a

+ 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服务启动成功 <解决微信支付精度丢失的问题> ( ´・・)ノ(._.`) \n" +
+        System.out.println("赞象SDK服务启动成功 <创角回传, 新增角色等级参数> ( ´・・)ノ(._.`) \n" +
                 " ___________ _   __\n" +
                 "/  ___|  _  \\ | / /\n" +
                 "\\ `--.| | | | |/ / \n" +

+ 4 - 0
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/CallBackServiceImpl.java

@@ -377,6 +377,7 @@ public class CallBackServiceImpl implements ICallBackService {
                 .userActionSetId(agent.getUserActionSetId())
                 .roleId(gameUserRole.getRoleId())
                 .roleName(gameUserRole.getRoleName())
+                .roleLevel(gameUserRole.getRoleLevel())
                 .build();
     }
 
@@ -390,6 +391,7 @@ public class CallBackServiceImpl implements ICallBackService {
                 .agentKey(agent.getAgentKey())
                 .roleId(gameUserRole.getRoleId())
                 .roleName(gameUserRole.getRoleName())
+                .roleLevel(gameUserRole.getRoleLevel())
                 .registerTime(gameUserRole.getCreateTime())
                 .build();
     }
@@ -521,6 +523,7 @@ public class CallBackServiceImpl implements ICallBackService {
                 .agentKey(agent.getAgentKey())
                 .roleId(gameUserRole.getRoleId())
                 .roleName(gameUserRole.getRoleName())
+                .roleLevel(gameUserRole.getRoleLevel())
                 .registerTime(gameUserRole.getCreateTime())
                 .mac(user.getMac())
                 .imei(user.getImei())
@@ -587,6 +590,7 @@ public class CallBackServiceImpl implements ICallBackService {
                 .channel(agent.getAgentKey())
                 .roleId(gameUserRole.getRoleId())
                 .roleName(gameUserRole.getRoleName())
+                .roleLevel(gameUserRole.getRoleLevel())
                 .mac(user.getMac())
                 .imei(user.getImei())
                 .oaid(user.getOaid())

+ 6 - 0
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/CpPushDataServiceImpl.java

@@ -392,6 +392,8 @@ public class CpPushDataServiceImpl implements ICpPushDataService {
                 0L, 20L, TimeUnit.SECONDS)) {
             return Boolean.TRUE;
         }
+        //判断是否等级变更
+        boolean updateRoleLevel = gameUserRole.getRoleLevel() != null && param.getRoleLevel() > gameUserRole.getRoleLevel();
         //玩家角色信息更新
         if (param.getExtra() != null && Strings.isNotBlank(JsonUtil.toString(param.getExtra()))) {
             gameUserRole.setExtra(JsonUtil.toString(param.getExtra()));
@@ -410,6 +412,10 @@ public class CpPushDataServiceImpl implements ICpPushDataService {
         gameUserRole.setServerName(param.getServerName());
         gameUserRole.setUpdateTime(LocalDateTime.now());
         boolean result = gameUserRoleService.updateById(gameUserRole);
+        //等级更新, 创角回传
+        if (updateRoleLevel) {
+            callBackService.roleCallBack(gameUserRole);
+        }
         //角色更新数据埋点发送到卡夫卡
         kafkaService.eventTrack(KafkaEventTrackEnum.KAFKA_EVENT_TRACK_ROLE_UPDATE, JsonUtil.toString(gameUserRole));
         return result;

+ 11 - 16
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/GameUserRoleServiceImpl.java

@@ -111,15 +111,8 @@ public class GameUserRoleServiceImpl extends ServiceImpl<GameUserRoleMapper, Gam
                 .eq(GameUserRole::getRoleId, gameUserRoleParam.getRoleId()));
         //更新游戏角色
         if (gameUserRole != null) {
-            //判断是否等级变更
-            boolean updateRoleLevel = gameUserRoleParam.getRoleLevel() > gameUserRole.getRoleLevel();
             //角色更新
-            this.gameRoleUpdate(gameUserRoleParam, gameUserRole, userData);
-            //玩家消息推送
-            if (updateRoleLevel) {
-                pushMsgService.pushMsgByLevelUpdate(gameUserRoleParam, userData);
-            }
-            return Boolean.TRUE;
+            return this.gameRoleUpdate(gameUserRoleParam, gameUserRole, userData);
         }
         //新建游戏角色
         this.gameRoleCreate(gameUserRoleParam, userData);
@@ -168,15 +161,8 @@ public class GameUserRoleServiceImpl extends ServiceImpl<GameUserRoleMapper, Gam
         }
         //等级提升更新
         if (gameUserRole != null && Objects.equals(dataType, DataTypeEnum.TYPE_LEVEL_UP.getDateType())) {
-            //判断是否等级变更
-            boolean updateRoleLevel = param.getRoleLevel() > gameUserRole.getRoleLevel();
             //角色更新
-            boolean result = this.gameRoleUpdate(param, gameUserRole, userData);
-            //玩家消息推送
-            if (updateRoleLevel) {
-                pushMsgService.pushMsgByLevelUpdate(param, userData);
-            }
-            return result;
+            return this.gameRoleUpdate(param, gameUserRole, userData);
         }
         //退出游戏
         if (Objects.equals(dataType, DataTypeEnum.TYPE_EXIT_GAME.getDateType())) {
@@ -193,6 +179,8 @@ public class GameUserRoleServiceImpl extends ServiceImpl<GameUserRoleMapper, Gam
                 0L, 20L, TimeUnit.SECONDS)) {
             return Boolean.TRUE;
         }
+        //判断是否等级变更
+        boolean updateRoleLevel = param.getRoleLevel() > gameUserRole.getRoleLevel();
         //玩家信息
         GameUser gameUser = gameUserService.getOne(new LambdaQueryWrapper<GameUser>()
                 .eq(GameUser::getGameId, userData.getGameId())
@@ -218,6 +206,13 @@ public class GameUserRoleServiceImpl extends ServiceImpl<GameUserRoleMapper, Gam
         gameUserRole.setServerName(param.getServerName());
         gameUserRole.setUpdateTime(LocalDateTime.now());
         boolean result = super.updateById(gameUserRole);
+        //等级变更
+        if (updateRoleLevel) {
+            //用户创角回传
+            callBackService.roleCallBack(gameUserRole);
+            //玩家消息推送
+            pushMsgService.pushMsgByLevelUpdate(param, userData);
+        }
         //角色更新数据埋点发送到卡夫卡
         kafkaService.eventTrack(KafkaEventTrackEnum.KAFKA_EVENT_TRACK_ROLE_UPDATE, JsonUtil.toString(gameUserRole));
         return result;