Sfoglia il codice sorgente

企业微信思域回传

wcc 9 mesi fa
parent
commit
454d03a495

+ 6 - 1
game-back/game-back-base/src/main/java/com/zanxiang/game/back/base/pojo/dto/TencentAppApiUserAgentQueryRpcDTO.java

@@ -3,6 +3,7 @@ package com.zanxiang.game.back.base.pojo.dto;
 import lombok.Data;
 
 import java.io.Serializable;
+import java.time.LocalDateTime;
 
 @Data
 public class TencentAppApiUserAgentQueryRpcDTO implements Serializable {
@@ -10,7 +11,11 @@ public class TencentAppApiUserAgentQueryRpcDTO implements Serializable {
 
     private Long gameId;
 
-    private String userId;
+    private String regIp;
+    /**
+     * 注册时间
+     */
+    private LocalDateTime registerTime;
 
     /**
      * 设备唯一编号IMEI

+ 2 - 0
game-back/game-back-base/src/main/java/com/zanxiang/game/back/base/pojo/dto/TencentUserAppApiRpcDTO.java

@@ -76,4 +76,6 @@ public class TencentUserAppApiRpcDTO implements Serializable {
      * 数据源ID
      */
     private Long userActionSetId;
+
+    private Long callbackId;
 }

+ 2 - 1
game-back/game-back-base/src/main/java/com/zanxiang/game/back/base/rpc/ITencentAppApiBackRpc.java

@@ -1,5 +1,6 @@
 package com.zanxiang.game.back.base.rpc;
 
+import com.github.sd4324530.jtuple.Tuple2;
 import com.zanxiang.game.back.base.pojo.dto.*;
 import com.zanxiang.module.util.pojo.ResultVO;
 
@@ -19,5 +20,5 @@ public interface ITencentAppApiBackRpc {
 
     ResultVO<Boolean> backRoleRegister(TencentRoleRegisterAppApiRpcDTO dto);
 
-    ResultVO<String> queryUserAgentFromCallback(TencentAppApiUserAgentQueryRpcDTO dto);
+    ResultVO<Tuple2<String, Long>> queryUserAgentFromCallback(TencentAppApiUserAgentQueryRpcDTO dto);
 }

+ 12 - 12
game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/rpc/impl/TencentAppApiBackRpcImpl.java

@@ -1,6 +1,7 @@
 package com.zanxiang.game.back.serve.rpc.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.github.sd4324530.jtuple.Tuple2;
 import com.zanxiang.game.back.base.pojo.dto.*;
 import com.zanxiang.game.back.base.pojo.enums.OrderStatusEnum;
 import com.zanxiang.game.back.base.rpc.ITencentAppApiBackRpc;
@@ -15,6 +16,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.dubbo.config.annotation.DubboService;
 import org.springframework.beans.factory.annotation.Autowired;
+import reactor.util.function.Tuples;
 
 import java.time.LocalDateTime;
 import java.util.Objects;
@@ -77,8 +79,12 @@ public class TencentAppApiBackRpcImpl implements ITencentAppApiBackRpc {
                 .createTime(LocalDateTime.now())
                 .build();
 
-        GameTencentAppCallback callback = gameTencentAppCallbackService.getUserCallback(userLog.getGameId(), userLog.getImei(), userLog.getOaid(), userLog.getAndroidId(), userLog.getIdfa(), userLog.getCaid(), userLog.getIp(), userLog.getRegisterTime());
-        userLog.setCallbackId(callback == null ? -1L : callback.getId());
+        if(dto.getCallbackId() != null) {
+            userLog.setCallbackId(dto.getCallbackId());
+        } else  {
+            GameTencentAppCallback callback = gameTencentAppCallbackService.getUserCallback(userLog.getGameId(), userLog.getImei(), userLog.getOaid(), userLog.getAndroidId(), userLog.getIdfa(), userLog.getCaid(), userLog.getIp(), userLog.getRegisterTime());
+            userLog.setCallbackId(callback == null ? -1L : callback.getId());
+        }
         gameTencentAppApiUserService.save(userLog);
         return ResultVO.ok(true);
         // 激活现在默认不回传了,等创角的时候一起回传
@@ -207,17 +213,11 @@ public class TencentAppApiBackRpcImpl implements ITencentAppApiBackRpc {
     }
 
     @Override
-    public ResultVO<String> queryUserAgentFromCallback(TencentAppApiUserAgentQueryRpcDTO dto) {
-        GameTencentAppApiUser user = gameTencentAppApiUserService.getOne(new LambdaQueryWrapper<GameTencentAppApiUser>()
-                .eq(GameTencentAppApiUser::getGameId, dto.getGameId())
-                .eq(GameTencentAppApiUser::getUserId, dto.getUserId())
-                .orderByDesc(GameTencentAppApiUser::getCreateTime)
-                .last("limit 1")
-        );
-        if(user == null || user.getCallbackId() == null || user.getCallbackId() < 1) {
+    public ResultVO<Tuple2<String, Long>> queryUserAgentFromCallback(TencentAppApiUserAgentQueryRpcDTO dto) {
+        GameTencentAppCallback callback = gameTencentAppCallbackService.getUserCallback(dto.getGameId(), dto.getImei(), dto.getOaid(), dto.getAndroidId(), dto.getIdfa(), dto.getCaid(), dto.getRegIp(), dto.getRegisterTime());
+        if(callback == null) {
             return ResultVO.ok(null);
         }
-        GameTencentAppCallback callback = gameTencentAppCallbackService.getById(user.getCallbackId());
-        return ResultVO.ok(callback.getAgentKey());
+        return ResultVO.ok(Tuple2.with(callback.getAgentKey(), callback.getId()));
     }
 }