Browse Source

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

zhimo 11 tháng trước cách đây
mục cha
commit
6927854b92

+ 1 - 0
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/impl/IActiveDataServiceImpl.java

@@ -126,6 +126,7 @@ public class IActiveDataServiceImpl implements IActiveDataService {
     public Page<ActiveDataDayVO> getActiveDataDay(ActiveDataDayDTO dto) {
         com.github.sd4324530.jtuple.Tuple2<List<Long>, List<Long>> poerInfo = dataPowerComponent.getPowerInfo();
         List<Long> userGameIds = dto.getGameId() == null ? poerInfo.second : dto.getGameId();
+//        List<Long> userGameIds = dto.getGameId();
 
         //默认查询的字段及表名
         String gameColumn = "game_id";

+ 51 - 9
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/task/OrderCostMonitorAlarmTask.java

@@ -8,10 +8,8 @@ import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
 import java.time.LocalDateTime;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
+import java.util.List;
+import java.util.concurrent.*;
 
 /**
  * @author ZhangXianyu
@@ -33,13 +31,11 @@ public class OrderCostMonitorAlarmTask {
 
 
 
-    /**
-     * 任务每10分钟运行一次
-     */
-    @Scheduled(cron = "0 0/10 * * * ? ")
+
+    @Deprecated
     public void run() {
+        log.info("订单与消耗监控告警定时任务开始.");
         Future<?> future =  taskScheduler.submit(() -> {
-            log.info("订单与消耗监控告警定时任务开始.");
             //本地不运行
             if (!run) {
                 return;
@@ -71,4 +67,50 @@ public class OrderCostMonitorAlarmTask {
         }
     }
 
+
+    /**
+     * 任务每10分钟运行一次
+     */
+    @Scheduled(cron = "0 0/10 * * * ? ")
+    public void runTask(){
+        log.info("订单与消耗监控告警定时任务开始.");
+        ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
+        Runnable task = ()->{
+            try {
+                //0点0分到0点30分不执行
+                LocalDateTime now = LocalDateTime.now();
+                if (now.getHour() == 0 && now.getMinute() <= 30) {
+                    return;
+                }
+                //监控订单表
+                orderCostMonitorAlarmService.monitorDataStatus();
+                //监控头条广告消耗表
+                orderCostMonitorAlarmService.monitorHeadCostStatus();
+                //监控腾讯广告消耗表
+                orderCostMonitorAlarmService.monitorTencentCostStatus();
+                log.info("订单与消耗监控告警定时任务结束.");
+            }catch (Exception e){
+                log.error("定时任务订单与消耗监控告警超时", e);
+            }
+        };
+        scheduler.submit(task);
+        // 使用shutdown()优雅关闭
+        scheduler.shutdown();
+        try {
+            // 等待所有任务完成,最多等待120秒
+            if (!scheduler.awaitTermination(120, TimeUnit.SECONDS)) {
+                log.info("线程池关闭超时,可能有任务未完成");
+            }
+        } catch (InterruptedException e) {
+            // 当前线程被中断,通常应重新中断自己
+            log.info("线程池关闭时当前线程被中断");
+            Thread.currentThread().interrupt();
+
+        }
+
+        // 或使用shutdownNow()强制关闭
+        List<Runnable> notStartedTasks = scheduler.shutdownNow();
+        log.info("已取消 " + notStartedTasks.size() + " 个任务");
+    }
+
 }

+ 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方的问题01> ( ´・・)ノ(._.`) \n" +
+        System.out.println("赞象SDK服务启动成功 <解决导量玩家重回小程序充值userId不正确的问题> ( ´・・)ノ(._.`) \n" +
                 " ___________ _   __\n" +
                 "/  ___|  _  \\ | / /\n" +
                 "\\ `--.| | | | |/ / \n" +

+ 8 - 2
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/PerformOrderServiceImpl.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.zanxiang.game.module.base.pojo.enums.CpStatusEnum;
+import com.zanxiang.game.module.base.pojo.enums.GameCategoryEnum;
 import com.zanxiang.game.module.base.util.DateUtils;
 import com.zanxiang.game.module.mybatis.entity.*;
 import com.zanxiang.game.module.sdk.enums.OrderStateEnum;
@@ -69,6 +70,9 @@ public class PerformOrderServiceImpl implements IPerformOrderService {
     @Autowired
     private IGameAppletService gameAppletService;
 
+    @Autowired
+    private IGameService gameService;
+
     @Override
     @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
     public Boolean pushCp(PlatformOrderDTO orderInfo) {
@@ -82,12 +86,14 @@ public class PerformOrderServiceImpl implements IPerformOrderService {
             log.error("充值回调CP失败, 游戏拓展信息中的回调地址为空!");
             return false;
         }
+        //游戏信息
+        Game game = gameService.getById(orderInfo.getGameId());
         //用户信息
         User user = userService.getById(orderInfo.getUserId());
         //回调CP
         Map<String, String> map = new HashMap<>(9);
-        //用户存在关联用户id, 且游戏存在导量游戏id, 判定为导量用户, 提交CP原始用户id
-        if (user.getRelationUserId() != null) {
+        //用户存在关联用户id, 且不是微信小程序, 则判定为导量用户, 提交CP原始用户id
+        if (user.getRelationUserId() != null && !Objects.equals(game.getCategory(), GameCategoryEnum.CATEGORY_WX_APPLET.getId())) {
             map.put("userId", String.valueOf(user.getRelationUserId()));
         } else {
             map.put("userId", String.valueOf(orderInfo.getUserId()));