Selaa lähdekoodia

feat : 消息推送策略修复空指针问题

bilingfeng 10 kuukautta sitten
vanhempi
commit
2fc450e4eb

+ 1 - 1
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/ManageApplication.java

@@ -23,7 +23,7 @@ public class ManageApplication {
 
     public static void main(String[] args) {
         SpringApplication.run(ManageApplication.class, args);
-        System.out.println("赞象Manage服务启动成功 < (消息推送策略01・・)ノ(._.`) \n" +
+        System.out.println("赞象Manage服务启动成功 < (消息推送策略, 修复空指针问题・・)ノ(._.`) \n" +
                 "___  ___  ___   _   _   ___  _____  _____ \n" +
                 "|  \\/  | / _ \\ | \\ | | / _ \\|  __ \\|  ___|\n" +
                 "| .  . |/ /_\\ \\|  \\| |/ /_\\ \\ |  \\/| |__  \n" +

+ 3 - 8
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/rpc/impl/PushMsgRpcImpl.java

@@ -11,7 +11,6 @@ import com.zanxiang.game.module.manage.service.IPushMsgStrategyService;
 import com.zanxiang.game.module.mybatis.entity.PushMsgSendResult;
 import com.zanxiang.game.module.mybatis.entity.PushMsgStrategy;
 import com.zanxiang.module.redis.service.IDistributedLockComponent;
-import com.zanxiang.module.util.JsonUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -44,10 +43,8 @@ public class PushMsgRpcImpl implements IPushMsgRpc {
     @Async
     @Override
     public void pushMsgByRecharge(PushMsgParam param) {
-        log.error("消息推送, 接收到充值消息, param : {}", JsonUtil.toString(param));
         //全局策略控制是否限制
         if (this.defaultStrategyCheck(param)) {
-            log.error("充值消息, 全局策略判断不执行, param : {}", JsonUtil.toString(param));
             return;
         }
         //查询充值策略
@@ -57,7 +54,6 @@ public class PushMsgRpcImpl implements IPushMsgRpc {
                 .orderByDesc(PushMsgStrategy::getCreateTime)
                 .last("limit 1"));
         if (pushMsgStrategy == null) {
-            log.error("充值消息, 查询策略为空, param : {}", JsonUtil.toString(param));
             return;
         }
         pushMsgStrategyService.strategyPushMsgRun(pushMsgStrategy, param);
@@ -66,18 +62,15 @@ public class PushMsgRpcImpl implements IPushMsgRpc {
     @Async
     @Override
     public void pushMsgByLevelUpdate(PushMsgParam param) {
-        log.error("消息推送,, 接收到等级更新消息, param : {}", JsonUtil.toString(param));
         //等级变更, 过滤战力变化, 1小时执行一次
         String lock = RedisKeyConstant.GAME_USER_ROLE_UP_LOCK + param.getUserId() + "_" + param.getGameId() + "_"
                 + param.getServerId() + "_" + param.getRoleId();
         if (!distributedLockComponent.doLock(lock, 0L, 10L, TimeUnit.MINUTES)) {
-            log.error("消息推送, 等级变化碰撞线程锁, 消息不执行 param : {}", JsonUtil.toString(param));
             return;
         }
         try {
             //全局策略控制是否限制
             if (this.defaultStrategyCheck(param)) {
-                log.error("等级更新消息, 全局策略判断不执行, param : {}", JsonUtil.toString(param));
                 return;
             }
             //查询等级策略
@@ -89,7 +82,6 @@ public class PushMsgRpcImpl implements IPushMsgRpc {
                     .orderByDesc(PushMsgStrategy::getCreateTime)
                     .last("limit 1"));
             if (pushMsgStrategy == null) {
-                log.error("等级更新消息, 查询策略为空, param : {}", JsonUtil.toString(param));
                 return;
             }
             pushMsgStrategyService.strategyPushMsgRun(pushMsgStrategy, param);
@@ -106,6 +98,9 @@ public class PushMsgRpcImpl implements IPushMsgRpc {
                 .eq(PushMsgStrategy::getGameId, param.getGameId())
                 .orderByDesc(PushMsgStrategy::getCreateTime)
                 .last("limit 1"));
+        if (defaultStrategy == null) {
+            return Boolean.TRUE;
+        }
         //判断今日推送次数是否已限制
         if (defaultStrategy.getSendCountMax() != null && pushMsgSendResultService.count(new LambdaQueryWrapper<PushMsgSendResult>()
                 .eq(PushMsgSendResult::getGameId, param.getGameId())