Переглянути джерело

fix : 腾讯SDK媒体回传业务逻辑修改提交

bilingfeng 3 місяців тому
батько
коміт
cf0289f99f
16 змінених файлів з 108 додано та 80 видалено
  1. 2 2
      game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/enums/BanStatusEnum.java
  2. 2 2
      game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/enums/CpStatusEnum.java
  3. 2 2
      game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/enums/DeleteEnum.java
  4. 2 2
      game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/enums/GameAuthEnum.java
  5. 3 3
      game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/enums/GameCategoryEnum.java
  6. 2 2
      game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/enums/H5SignShowEnum.java
  7. 2 2
      game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/enums/H5WeChatControlEnum.java
  8. 3 3
      game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/enums/OsEnum.java
  9. 2 2
      game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/enums/PayApplicationTypeEnum.java
  10. 3 3
      game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/enums/PayDeviceEnum.java
  11. 3 3
      game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/enums/PayWayEnum.java
  12. 2 2
      game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/enums/ShellControlEnum.java
  13. 2 2
      game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/enums/StatusEnum.java
  14. 1 1
      game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/SDKApplication.java
  15. 44 12
      game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/GameBackLogMediaSdkServiceImpl.java
  16. 33 37
      game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/GameServiceImpl.java

+ 2 - 2
game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/enums/BanStatusEnum.java

@@ -25,11 +25,11 @@ public enum BanStatusEnum {
     /**
      * 状态
      */
-    private Integer status;
+    private final Integer status;
 
     /**
      * 描述
      */
-    private String describe;
+    private final String describe;
 
 }

+ 2 - 2
game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/enums/CpStatusEnum.java

@@ -29,10 +29,10 @@ public enum CpStatusEnum {
     /**
      * 类型
      */
-    private Integer status;
+    private final Integer status;
 
     /**
      * 描述
      */
-    private String desc;
+    private final String desc;
 }

+ 2 - 2
game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/enums/DeleteEnum.java

@@ -24,10 +24,10 @@ public enum DeleteEnum {
     /**
      *
      */
-    private int code;
+    private final int code;
 
     /**
      * 状态
      */
-    private String name;
+    private final String name;
 }

+ 2 - 2
game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/enums/GameAuthEnum.java

@@ -49,12 +49,12 @@ public enum GameAuthEnum {
     /**
      * 角色
      */
-    private String value;
+    private final String value;
 
     /**
      * 名称
      */
-    private String name;
+    private final String name;
 
     /**
      * 根据值获取枚举对象

+ 3 - 3
game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/enums/GameCategoryEnum.java

@@ -37,17 +37,17 @@ public enum GameCategoryEnum {
     /**
      * 应用id
      */
-    private Long id;
+    private final Long id;
 
     /**
      * 游戏分类key
      */
-    private String categoryKey;
+    private final String categoryKey;
 
     /**
      * 描述
      */
-    private String name;
+    private final String name;
 
     /**
      * 被分类名字

+ 2 - 2
game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/enums/H5SignShowEnum.java

@@ -35,10 +35,10 @@ public enum H5SignShowEnum {
     /**
      * 展示类型
      */
-    private String value;
+    private final String value;
 
     /**
      * 描述
      */
-    private String describe;
+    private final String describe;
 }

+ 2 - 2
game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/enums/H5WeChatControlEnum.java

@@ -30,11 +30,11 @@ public enum H5WeChatControlEnum {
     /**
      * 展示类型
      */
-    private String value;
+    private final String value;
 
     /**
      * 描述
      */
-    private String describe;
+    private final String describe;
 
 }

+ 3 - 3
game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/enums/OsEnum.java

@@ -52,17 +52,17 @@ public enum OsEnum {
     /**
      * 数据类型
      */
-    private Integer osType;
+    private final Integer osType;
 
     /**
      * 平台id
      */
-    private String os;
+    private final String os;
 
     /**
      * 平台名称
      */
-    private String osName;
+    private final String osName;
 
 
     /**

+ 2 - 2
game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/enums/PayApplicationTypeEnum.java

@@ -30,12 +30,12 @@ public enum PayApplicationTypeEnum {
     /**
      * 应用类型
      */
-    private Integer type;
+    private final Integer type;
 
     /**
      * 描述
      */
-    private String describe;
+    private final String describe;
 
     public static String getDescByType(Integer type) {
         PayApplicationTypeEnum[] values = PayApplicationTypeEnum.values();

+ 3 - 3
game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/enums/PayDeviceEnum.java

@@ -56,17 +56,17 @@ public enum PayDeviceEnum {
     /**
      * 支付方式id
      */
-    private Long payDeviceId;
+    private final Long payDeviceId;
 
     /**
      * 支付方式key
      */
-    private String payDeviceKey;
+    private final String payDeviceKey;
 
     /**
      * 支付方式名称
      */
-    private String payDeviceName;
+    private final String payDeviceName;
 
     /**
      * 根据支付方式id获取名称

+ 3 - 3
game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/enums/PayWayEnum.java

@@ -34,17 +34,17 @@ public enum PayWayEnum {
     /**
      * 支付渠道id
      */
-    private Integer payWayId;
+    private final Integer payWayId;
 
     /**
      * 支付渠道key
      */
-    private String payWayKey;
+    private final String payWayKey;
 
     /**
      * 支付渠道名称
      */
-    private String payWayName;
+    private final String payWayName;
 
     /**
      * 根据支付类型id获取名称

+ 2 - 2
game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/enums/ShellControlEnum.java

@@ -40,10 +40,10 @@ public enum ShellControlEnum {
     /**
      * 壳包控制类型
      */
-    private Integer shellControl;
+    private final Integer shellControl;
 
     /**
      * 描述
      */
-    private String name;
+    private final String name;
 }

+ 2 - 2
game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/enums/StatusEnum.java

@@ -24,10 +24,10 @@ public enum StatusEnum {
     /**
      * 状态
      */
-    private int code;
+    private final int code;
 
     /**
      * 描述
      */
-    private String name;
+    private final String name;
 }

+ 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服务启动成功 <绑定手机号新增3个接口> ( ´・・)ノ(._.`) \n" +
+        System.out.println("赞象SDK服务启动成功 <腾讯SDK媒体回传业务逻辑修改提交> ( ´・・)ノ(._.`) \n" +
                 " ___________ _   __\n" +
                 "/  ___|  _  \\ | / /\n" +
                 "\\ `--.| | | | |/ / \n" +

+ 44 - 12
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/GameBackLogMediaSdkServiceImpl.java

@@ -15,6 +15,7 @@ import com.zanxiang.game.back.base.rpc.ITencentMiniGameBackRpc;
 import com.zanxiang.game.back.base.rpc.ITtAppBackRpc;
 import com.zanxiang.game.module.base.pojo.enums.AccountTypeEnum;
 import com.zanxiang.game.module.base.pojo.enums.GameCategoryEnum;
+import com.zanxiang.game.module.base.pojo.enums.PayDeviceEnum;
 import com.zanxiang.game.module.mybatis.entity.*;
 import com.zanxiang.game.module.mybatis.mapper.GameBackLogMediaSdkMapper;
 import com.zanxiang.game.module.sdk.constant.RedisKeyConstant;
@@ -107,7 +108,7 @@ public class GameBackLogMediaSdkServiceImpl extends ServiceImpl<GameBackLogMedia
                 return resultMap;
             }
             //玩家渠道信息回传检测
-            Tuple2<Boolean, Agent> userAgentCheckTuple2 = this.userAgentCheck(user, resultMap);
+            Tuple2<Boolean, Agent> userAgentCheckTuple2 = this.userAgentCheck(user, resultMap, param);
             if (!userAgentCheckTuple2.first) {
                 return resultMap;
             }
@@ -257,27 +258,42 @@ public class GameBackLogMediaSdkServiceImpl extends ServiceImpl<GameBackLogMedia
         return true;
     }
 
-    private Tuple2<Boolean, Agent> userAgentCheck(User user, Map<String, Object> resultMap) {
-        //判断玩家是否为自然量或者被分享用户, 是则不执行回传
-        if (Objects.equals(user.getAgentId(), Agent.DEFAULT_AGENT) || user.getShareUserId() != null) {
+    private Tuple2<Boolean, Agent> userAgentCheck(User user, Map<String, Object> resultMap, CallBackControlParam param) {
+        //玩家渠道
+        Agent agent = agentService.getById(user.getAgentId());
+        //买量用户, 返回执行回传, 且返回渠道信息
+        if (agent != null && user.getShareUserId() == null) {
+            return Tuple2.with(Boolean.TRUE, agent);
+        }
+        //查询游戏
+        Game game = gameService.getById(user.getGameId());
+        //非买量, 安卓APP, 不回传
+        if (Objects.equals(game.getCategory(), GameCategoryEnum.CATEGORY_APP.getId())) {
             resultMap.put("backMsg", "玩家属于自然量或者被分享用户, 不回传");
             return Tuple2.with(Boolean.FALSE, null);
         }
-        //判断玩家是否存在渠道, 不存在渠道则不回传
-        Agent agent = agentService.getById(user.getAgentId());
-        if (agent == null) {
-            resultMap.put("backMsg", "根据玩家渠道id查询渠道信息为空, 无法执行回传");
+        //非买量, 新手引导无法回传
+        if (Objects.equals(param.getCallBackTypeEnum(), CallBackTypeEnum.CALL_BACK_TUTORIAL_FINISH)) {
+            resultMap.put("backMsg", "非买量, 新手引导回传无法判定, 不回传");
             return Tuple2.with(Boolean.FALSE, null);
         }
-        //返回执行回传, 且返回渠道信息
-        return Tuple2.with(Boolean.TRUE, agent);
+        //非买量, 订单回传, 不继续判断, 直接回传
+        if (Objects.equals(param.getCallBackTypeEnum(), CallBackTypeEnum.CALL_BACK_PAY_ORDER)) {
+            resultMap.put("callBack", Boolean.TRUE);
+            resultMap.put("backMsg", "微信小游戏自然量订单全量回传");
+            PlatformOrderDTO platformOrderDTO = orderService.getByOrderId(param.getOrderId());
+            resultMap.put("amount", platformOrderDTO.getAmount().longValue() * 100);
+            return Tuple2.with(Boolean.FALSE, null);
+        }
+        //其他回传, 还是走判断
+        return Tuple2.with(Boolean.TRUE, null);
     }
 
     private void checkCallBack(User user, Agent agent, Map<String, Object> resultMap, CallBackControlParam param) {
         //玩家id
         Long userId = user.getId();
         //游戏id
-        Long gameId = agent.getGameId();
+        Long gameId = user.getGameId();
         //角色id
         String roleId = param.getRoleId();
         //角色等级
@@ -484,7 +500,7 @@ public class GameBackLogMediaSdkServiceImpl extends ServiceImpl<GameBackLogMedia
             doBack = orderBackQueryRpcVO.getDoBack();
             backMsg = orderBackQueryRpcVO.getBackMsg();
         }
-        //腾讯小游戏媒体SDK回传
+        //腾讯小游戏投腾讯广告
         if (Objects.equals(agent.getAccountType(), AccountTypeEnum.TENCENT_MINI_GAME.getValue())) {
             TencentMiniGameOrderBackQueryRpcDTO orderQuery = this.transform(user.getOpenId(), orderId, agent);
             OrderBackQueryRpcVO orderBackQueryRpcVO = tencentMiniGameBackRpc.orderBackQuery(orderQuery).getData();
@@ -493,6 +509,22 @@ public class GameBackLogMediaSdkServiceImpl extends ServiceImpl<GameBackLogMedia
             }
             doBack = orderBackQueryRpcVO.getDoBack();
             backMsg = orderBackQueryRpcVO.getBackMsg();
+            //米大师支付会被监听, 漏单修正, 直接更改结果为回传1分钱
+            if (Objects.equals(orderBackQueryRpcVO.getDoBack(), Boolean.FALSE)) {
+                PlatformOrderDTO platformOrderDTO = orderService.getByOrderId(orderId);
+                if (Objects.equals(platformOrderDTO.getPayDeviceId(), PayDeviceEnum.MI_PAY.getPayDeviceId())) {
+                    doBack = Boolean.TRUE;
+                    amount = Collections.singletonList(1L);
+                    backMsg = "米大师漏单, 修改回传金额为1分钱回传";
+                }
+            }
+        }
+        //微信小游戏投巨量广告 (坑逼腾讯要其他渠道的订单数据)
+        if (Objects.equals(agent.getAccountType(), AccountTypeEnum.BYTE.getValue())) {
+            PlatformOrderDTO platformOrderDTO = orderService.getByOrderId(orderId);
+            doBack = Boolean.TRUE;
+            amount = Collections.singletonList(platformOrderDTO.getAmount().longValue() * 100);
+            backMsg = "微信小游戏投巨量广告, 订单回传给腾讯媒体SDK";
         }
         return Tuple3.with(doBack, amount, Strings.isBlank(backMsg) ? "未知的渠道投放类型" : backMsg);
     }

+ 33 - 37
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/GameServiceImpl.java

@@ -1,14 +1,10 @@
 package com.zanxiang.game.module.sdk.service.impl;
 
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.sd4324530.jtuple.Tuple2;
-import com.zanxiang.game.module.base.pojo.enums.AccountTypeEnum;
-import com.zanxiang.game.module.base.pojo.enums.GameCategoryEnum;
 import com.zanxiang.game.module.mybatis.entity.Agent;
 import com.zanxiang.game.module.mybatis.entity.Game;
 import com.zanxiang.game.module.mybatis.entity.User;
-import com.zanxiang.game.module.mybatis.entity.UserEvent;
 import com.zanxiang.game.module.mybatis.mapper.GameMapper;
 import com.zanxiang.game.module.sdk.pojo.param.UserData;
 import com.zanxiang.game.module.sdk.service.IAgentService;
@@ -23,7 +19,6 @@ import org.springframework.stereotype.Service;
 
 import java.util.Collections;
 import java.util.Map;
-import java.util.Objects;
 
 /**
  * @author : lingfeng
@@ -49,38 +44,39 @@ public class GameServiceImpl extends ServiceImpl<GameMapper, Game> implements IG
         if (Strings.isBlank(game.getAdSdkConfig())) {
             return Collections.singletonMap("adSdk", 0);
         }
-        //判断是否为APP, APP直接返回配置
-        if (Objects.equals(game.getCategory(), GameCategoryEnum.CATEGORY_APP.getId())) {
-            return JsonUtil.toMap(game.getAdSdkConfig(), Map.class, Object.class);
-        }
-        //查询用户信息以及投放渠道
-        Tuple2<User, Agent> userAndAgent = this.getUserAndAgent(userData.getUserId());
-        User user = userAndAgent.first;
-        Agent agent = userAndAgent.second;
-        //渠道判断, 目前只有投腾讯才返回
-        if (agent != null) {
-            //腾讯广告
-            if (Objects.equals(agent.getAccountType(), AccountTypeEnum.TENCENT_MINI_GAME.getValue())) {
-                return JsonUtil.toMap(game.getAdSdkConfig(), Map.class, Object.class);
-            }
-            //头条广告
-            if (Objects.equals(agent.getAccountType(), AccountTypeEnum.BYTE.getValue())) {
-                return Collections.singletonMap("adSdk", 0);
-            }
-        }
-        //用户判断, 是否调试阶段和测试用户
-        if (user != null) {
-            if (Objects.equals(game.getStatus(), 2) || userEventService.count(new LambdaQueryWrapper<UserEvent>()
-                    .eq(UserEvent::getGameId, user.getGameId())
-                    .and(qw -> qw.eq(UserEvent::getUsername, user.getUsername())
-                            .or().eq(UserEvent::getUsername, user.getOpenId())
-                            .or().eq(UserEvent::getMobile, user.getMobile()))
-            ) > 0) {
-                return JsonUtil.toMap(game.getAdSdkConfig(), Map.class, Object.class);
-            }
-        }
-        //默认返回不初始化
-        return Collections.singletonMap("adSdk", 0);
+        return JsonUtil.toMap(game.getAdSdkConfig(), Map.class, Object.class);
+//        //判断是否为APP, APP直接返回配置
+//        if (Objects.equals(game.getCategory(), GameCategoryEnum.CATEGORY_APP.getId())) {
+//            return JsonUtil.toMap(game.getAdSdkConfig(), Map.class, Object.class);
+//        }
+//        //查询用户信息以及投放渠道
+//        Tuple2<User, Agent> userAndAgent = this.getUserAndAgent(userData.getUserId());
+//        User user = userAndAgent.first;
+//        Agent agent = userAndAgent.second;
+//        //渠道判断, 目前只有投腾讯才返回
+//        if (agent != null) {
+//            //腾讯广告
+//            if (Objects.equals(agent.getAccountType(), AccountTypeEnum.TENCENT_MINI_GAME.getValue())) {
+//                return JsonUtil.toMap(game.getAdSdkConfig(), Map.class, Object.class);
+//            }
+//            //头条广告
+//            if (Objects.equals(agent.getAccountType(), AccountTypeEnum.BYTE.getValue())) {
+//                return Collections.singletonMap("adSdk", 0);
+//            }
+//        }
+//        //用户判断, 是否调试阶段和测试用户
+//        if (user != null) {
+//            if (Objects.equals(game.getStatus(), 2) || userEventService.count(new LambdaQueryWrapper<UserEvent>()
+//                    .eq(UserEvent::getGameId, user.getGameId())
+//                    .and(qw -> qw.eq(UserEvent::getUsername, user.getUsername())
+//                            .or().eq(UserEvent::getUsername, user.getOpenId())
+//                            .or().eq(UserEvent::getMobile, user.getMobile()))
+//            ) > 0) {
+//                return JsonUtil.toMap(game.getAdSdkConfig(), Map.class, Object.class);
+//            }
+//        }
+//        //默认返回不初始化
+//        return Collections.singletonMap("adSdk", 0);
     }
 
     private Tuple2<User, Agent> getUserAndAgent(Long userId) {