Преглед на файлове

feat : 创角事件取消使用事件发布通知形式

bilingfeng преди 10 месеца
родител
ревизия
34710d9d32

+ 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服务启动成功 <角色创建新增自动操作记录, 解决CP方分享功能带来的坑> ( ´・・)ノ(._.`) \n" +
+        System.out.println("赞象SDK服务启动成功 <创角取消使用事件通知> ( ´・・)ノ(._.`) \n" +
                 " ___________ _   __\n" +
                 "/  ___|  _  \\ | / /\n" +
                 "\\ `--.| | | | |/ / \n" +

+ 3 - 10
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/GameUserRoleServiceImpl.java

@@ -10,7 +10,6 @@ import com.zanxiang.game.module.sdk.constant.RedisKeyConstant;
 import com.zanxiang.game.module.sdk.enums.DataTypeEnum;
 import com.zanxiang.game.module.sdk.enums.KafkaEventTrackEnum;
 import com.zanxiang.game.module.sdk.enums.LoginTypeEnum;
-import com.zanxiang.game.module.sdk.listener.GameRoleCreateEvent;
 import com.zanxiang.game.module.sdk.pojo.param.GameRoleActiveCallParam;
 import com.zanxiang.game.module.sdk.pojo.param.GameUserRoleSubmitParam;
 import com.zanxiang.game.module.sdk.pojo.param.GameUserRoleUpdateParam;
@@ -75,9 +74,8 @@ public class GameUserRoleServiceImpl extends ServiceImpl<GameUserRoleMapper, Gam
     @Autowired
     private IGameExtService gameExtService;
 
-    @Lazy
     @Autowired
-    private ApplicationContext applicationContext;
+    private IRoleOperateService roleOperateService;
 
     @Override
     public Boolean updateUserGameRole(GameUserRoleSubmitParam param) {
@@ -272,13 +270,8 @@ public class GameUserRoleServiceImpl extends ServiceImpl<GameUserRoleMapper, Gam
         kafkaService.eventTrack(KafkaEventTrackEnum.KAFKA_EVENT_TRACK_ROLE_CREATE, JsonUtil.toString(userRole));
         //创建角色通知监听服务
         this.callListenIn(param, userData);
-        //发布创角事件
-        try {
-            GameRoleCreateEvent gameRoleCreateEvent = new GameRoleCreateEvent(this, userRole);
-            applicationContext.publishEvent(gameRoleCreateEvent);
-        } catch (Exception e) {
-            log.error("创角事件发布异常, gameId : {}, role : {}", userRole.getGameId(), userRole.getRoleId());
-        }
+        //角色操作记录添加
+        roleOperateService.systemRoleOperate(userRole);
     }
 
     private GameUserRole transform(GameUserRoleUpdateParam param, UserData userData, GameUser gameUser, User user) {

+ 29 - 25
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/RoleOperateServiceImpl.java

@@ -33,32 +33,36 @@ public class RoleOperateServiceImpl extends ServiceImpl<RoleOperateMapper, RoleO
 
     @Override
     public void systemRoleOperate(GameUserRole gameUserRole) {
-        //查询玩家信息
-        User user = userService.getById(gameUserRole.getUserId());
-        //解析玩家渠道信息
-        Map<String, String> channelMap = agentService.channelTransform(user.getChannel());
-        if (!channelMap.containsKey("corpId") || !channelMap.containsKey("corpUserId")
-                || !channelMap.containsKey("externalUserId")) {
-            log.error("创角事件 : 非企微链路, 不做操作! gameId : {}, roleId : {}", gameUserRole.getGameId(), gameUserRole.getRoleId());
-            return;
+        try {
+            //查询玩家信息
+            User user = userService.getById(gameUserRole.getUserId());
+            //解析玩家渠道信息
+            Map<String, String> channelMap = agentService.channelTransform(user.getChannel());
+            if (!channelMap.containsKey("corpId") || !channelMap.containsKey("corpUserId")
+                    || !channelMap.containsKey("externalUserId")) {
+                log.error("创角非企微链路, 不做操作! gameId : {}, roleId : {}", gameUserRole.getGameId(), gameUserRole.getRoleId());
+                return;
+            }
+            //查询操作记录
+            RoleOperate roleOperate = super.getOne(new LambdaQueryWrapper<RoleOperate>()
+                    .eq(RoleOperate::getGameId, gameUserRole.getGameId())
+                    .eq(RoleOperate::getServerId, gameUserRole.getServerId())
+                    .eq(RoleOperate::getUserId, gameUserRole.getUserId())
+                    .eq(RoleOperate::getRoleId, gameUserRole.getRoleId()));
+            if (roleOperate == null) {
+                roleOperate = this.transform(gameUserRole, channelMap);
+            } else {
+                roleOperate.setCorpId(channelMap.get("corpId"));
+                roleOperate.setExternalUserId(channelMap.get("externalUserId"));
+                roleOperate.setAddCorpUserId(channelMap.get("corpUserId"));
+                roleOperate.setIsAddCorpWechat(1);
+                roleOperate.setUpdateBy(RoleOperate.SYSTEM_OPERATE);
+                roleOperate.setUpdateTime(LocalDateTime.now());
+            }
+            super.saveOrUpdate(roleOperate);
+        } catch (Exception e) {
+            log.error("创角添加记录异常! gameId : {}, roleId : {}", gameUserRole.getGameId(), gameUserRole.getRoleId());
         }
-        //查询操作记录
-        RoleOperate roleOperate = super.getOne(new LambdaQueryWrapper<RoleOperate>()
-                .eq(RoleOperate::getGameId, gameUserRole.getGameId())
-                .eq(RoleOperate::getServerId, gameUserRole.getServerId())
-                .eq(RoleOperate::getUserId, gameUserRole.getUserId())
-                .eq(RoleOperate::getRoleId, gameUserRole.getRoleId()));
-        if (roleOperate == null) {
-            roleOperate = this.transform(gameUserRole, channelMap);
-        } else {
-            roleOperate.setCorpId(channelMap.get("corpId"));
-            roleOperate.setExternalUserId(channelMap.get("externalUserId"));
-            roleOperate.setAddCorpUserId(channelMap.get("corpUserId"));
-            roleOperate.setIsAddCorpWechat(1);
-            roleOperate.setUpdateBy(RoleOperate.SYSTEM_OPERATE);
-            roleOperate.setUpdateTime(LocalDateTime.now());
-        }
-        super.saveOrUpdate(roleOperate);
     }
 
     private RoleOperate transform(GameUserRole gameUserRole, Map<String, String> channelMap) {