Parcourir la source

Merge branch 'package' of GameCenter/game-center into dev

zhimo il y a 1 an
Parent
commit
152c310cf1

+ 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服务启动成功 <小程序监听修改完成上线03> ( ´・・)ノ(._.`) \n" +
+        System.out.println("赞象Manage服务启动成功 <小程序监听修改上线> ( ´・・)ノ(._.`) \n" +
                 "___  ___  ___   _   _   ___  _____  _____ \n" +
                 "|  \\/  | / _ \\ | \\ | | / _ \\|  __ \\|  ___|\n" +
                 "| .  . |/ /_\\ \\|  \\| |/ /_\\ \\ |  \\/| |__  \n" +

+ 25 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/constant/RedisKeyConstant.java

@@ -0,0 +1,25 @@
+package com.zanxiang.game.module.manage.constant;
+
+/**
+ * @author : lingfeng
+ * @time : 2022-06-08
+ * @description : 缓存key前缀
+ */
+public class RedisKeyConstant {
+
+    /**
+     * 同步服务缓存统一前缀
+     */
+    private static final String REDIS_PREFIX = "game_manage_";
+
+    /**
+     * 阿里云固话呼叫锁
+     */
+    public static final String PHONE_CALL_LOCK = RedisKeyConstant.REDIS_PREFIX + "phoneCall_lock_";
+
+    /**
+     * 小程序支付应用任务锁
+     */
+    public static final String PAY_APP_CHECK_LOCK = RedisKeyConstant.REDIS_PREFIX + "payApplicationCheck_lock";
+
+}

+ 28 - 5
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/AppletCheckServiceImpl.java

@@ -11,11 +11,13 @@ import com.zanxiang.game.module.base.ServerInfo;
 import com.zanxiang.game.module.base.pojo.enums.PayApplicationTypeEnum;
 import com.zanxiang.game.module.base.pojo.enums.StatusEnum;
 import com.zanxiang.game.module.base.rpc.IWxApiServiceRpc;
+import com.zanxiang.game.module.manage.constant.RedisKeyConstant;
 import com.zanxiang.game.module.manage.service.*;
 import com.zanxiang.game.module.mybatis.entity.GamePayWay;
 import com.zanxiang.game.module.mybatis.entity.ListenCall;
 import com.zanxiang.game.module.mybatis.entity.PayApplication;
 import com.zanxiang.game.module.mybatis.entity.PayBox;
+import com.zanxiang.module.redis.service.IDistributedLockComponent;
 import com.zanxiang.module.util.JsonUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
@@ -33,6 +35,7 @@ import org.springframework.web.client.RestTemplate;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.*;
+import java.util.concurrent.TimeUnit;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
@@ -63,6 +66,9 @@ public class AppletCheckServiceImpl implements IAppletCheckService {
     @Autowired
     private IPayApplicationService payApplicationService;
 
+    @Autowired
+    private IDistributedLockComponent distributedLockComponent;
+
     @Override
     public void payApplicationCheck() {
         List<PayApplication> payApplicationList = payApplicationService.list(new LambdaQueryWrapper<PayApplication>()
@@ -178,7 +184,13 @@ public class AppletCheckServiceImpl implements IAppletCheckService {
         }
         String content = payApplication.getAppName() + "监测异常";
         Set<String> phoneNumSet = listenCallList.stream().map(ListenCall::getPhoneNum).collect(Collectors.toSet());
-        phoneNumSet.forEach(phoneNum -> this.phoneCall(content, phoneNum));
+        phoneNumSet.forEach(phoneNum -> {
+            String lockKey = RedisKeyConstant.PHONE_CALL_LOCK + phoneNum;
+            if (!distributedLockComponent.doLock(lockKey, 0L, 1L, TimeUnit.MINUTES)) {
+                return;
+            }
+            this.phoneCall(content, phoneNum);
+        });
     }
 
     private List<ListenCall> callListenUser() {
@@ -203,15 +215,26 @@ public class AppletCheckServiceImpl implements IAppletCheckService {
         try {
             // 带参POST请求
             String result = HttpUtil.post(host, JsonUtil.toString(paramMap));
-            if (Strings.isNotBlank(result) && result.contains("errcode")) {
-                log.error("小程序封停监测结果, appName : {}, result : {}", appName, result);
-                return Boolean.FALSE;
+            //结果为空, 判定腾讯接口返回错误, 不判定为封禁
+            if (Strings.isBlank(result)) {
+                return Boolean.TRUE;
+            }
+            //没有报错
+            if (!result.contains("errcode")) {
+                return Boolean.TRUE;
+            }
+            //结果返回错误
+            Map<String, Object> resultMap = JsonUtil.toMap(result, Map.class, Object.class);
+            //排除计算中的特殊报错
+            if (Objects.equals(resultMap.get("errcode").toString(), "61503")) {
+                return Boolean.TRUE;
             }
+            log.error("小程序封停监测结果, appName : {}, result : {}", appName, result);
         } catch (Exception e) {
             log.error("小程序封停监测异常, appName : {},  e : {}", appName, e.getMessage());
             return Boolean.FALSE;
         }
-        return Boolean.TRUE;
+        return Boolean.FALSE;
     }
 
     private void phoneCall(String param, String mobile) {

+ 3 - 3
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/task/PayApplicationTask.java

@@ -1,5 +1,6 @@
 package com.zanxiang.game.module.manage.task;
 
+import com.zanxiang.game.module.manage.constant.RedisKeyConstant;
 import com.zanxiang.game.module.manage.service.IAppletCheckService;
 import com.zanxiang.module.redis.service.IDistributedLockComponent;
 import lombok.extern.slf4j.Slf4j;
@@ -30,9 +31,8 @@ public class PayApplicationTask {
      */
     @Scheduled(cron = "0 0/10 * * * ?")
     public void payApplicationCheck() {
-        String lockKey = "payApplicationCheck_lock";
         //上锁
-        if (!distributedLockComponent.doLock(lockKey, 0L, 15L, TimeUnit.MINUTES)) {
+        if (!distributedLockComponent.doLock(RedisKeyConstant.PAY_APP_CHECK_LOCK, 0L, 15L, TimeUnit.MINUTES)) {
             return;
         }
         log.error("小程序每10分钟封停监控定时器开始执行, startTime : {}", LocalDateTime.now().toString());
@@ -43,7 +43,7 @@ public class PayApplicationTask {
             log.error("小程序每10分钟封停监控异常, e : {}", e.getMessage());
         } finally {
             //释放锁
-            distributedLockComponent.unlock(lockKey);
+            distributedLockComponent.unlock(RedisKeyConstant.PAY_APP_CHECK_LOCK);
         }
         log.error("小程序每10分钟封停监控定时器执行结束 , endTime  : {}", LocalDateTime.now().toString());
     }