Просмотр исходного кода

fix : 小游戏绑定手机号自动导量

bilingfeng 2 месяцев назад
Родитель
Сommit
104625e8a0

+ 18 - 0
game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/rpc/IUserRpc.java

@@ -0,0 +1,18 @@
+package com.zanxiang.game.module.base.rpc;
+
+/**
+ * @author : lingfeng
+ * @time : 2025-02-13
+ * @description : 玩家相关接口
+ */
+public interface IUserRpc {
+
+    /**
+     * 小游戏导量其他端
+     *
+     * @param userId : 玩家id
+     * @param gameId : 游戏id
+     * @param mobile : 手机号
+     */
+    void appletToOther(Long userId, Long gameId, String mobile);
+}

+ 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) {
     public static void main(String[] args) {
         SpringApplication.run(ManageApplication.class, args);
         SpringApplication.run(ManageApplication.class, args);
-        System.out.println("赞象Manage服务启动成功 < (IP解析历史数据处理新增线程池调试02 ・・)ノ(._.`) \n" +
+        System.out.println("赞象Manage服务启动成功 < (小游戏绑定手机号自动转端rpc接口新增 ・・)ノ(._.`) \n" +
                 "___  ___  ___   _   _   ___  _____  _____ \n" +
                 "___  ___  ___   _   _   ___  _____  _____ \n" +
                 "|  \\/  | / _ \\ | \\ | | / _ \\|  __ \\|  ___|\n" +
                 "|  \\/  | / _ \\ | \\ | | / _ \\|  __ \\|  ___|\n" +
                 "| .  . |/ /_\\ \\|  \\| |/ /_\\ \\ |  \\/| |__  \n" +
                 "| .  . |/ /_\\ \\|  \\| |/ /_\\ \\ |  \\/| |__  \n" +

+ 52 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/rpc/impl/UserRpcImpl.java

@@ -0,0 +1,52 @@
+package com.zanxiang.game.module.manage.rpc.impl;
+
+import com.zanxiang.game.module.base.rpc.IUserRpc;
+import com.zanxiang.game.module.manage.pojo.dto.GameDTO;
+import com.zanxiang.game.module.manage.service.IGameService;
+import com.zanxiang.game.module.manage.service.IUserService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.dubbo.config.annotation.DubboService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+
+/**
+ * @author : lingfeng
+ * @time : 2025-02-13
+ * @description : 玩家相关接口
+ */
+@Slf4j
+@DubboService
+public class UserRpcImpl implements IUserRpc {
+
+    @Autowired
+    private IUserService userService;
+
+    @Autowired
+    private IGameService gameService;
+
+    @Async
+    @Override
+    public void appletToOther(Long userId, Long gameId, String mobile) {
+        try {
+            //查询游戏信息
+            GameDTO gameDTO = gameService.getById(gameId);
+            if (gameDTO == null) {
+                return;
+            }
+            //判断是否存在H5端游戏
+            if (gameDTO.getH5GameId() != null) {
+                userService.appletToH5(userId, mobile, 1);
+            }
+            //判断是否存在安卓端APP游戏
+            if (gameDTO.getAndroidGameId() != null) {
+                userService.appletToH5(userId, mobile, 2);
+            }
+            //判断是否存在IOS端APP游戏
+            if (gameDTO.getIosGameId() != null) {
+                userService.appletToH5(userId, mobile, 3);
+            }
+        } catch (Exception e) {
+            log.error("执行玩家导量异常, userId : {}, mobile : {}, e : {}", userId, mobile, e.getMessage());
+        }
+    }
+}

+ 1 - 1
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/SDKApplication.java

@@ -25,7 +25,7 @@ public class SDKApplication {
 
 
     public static void main(String[] args) {
     public static void main(String[] args) {
         SpringApplication.run(SDKApplication.class, args);
         SpringApplication.run(SDKApplication.class, args);
-        System.out.println("赞象SDK服务启动成功 <仙剑APP导量玩家禁止充值, 引导回小程序充值> ( ´・・)ノ(._.`) \n" +
+        System.out.println("赞象SDK服务启动成功 <小游戏绑定手机号自动转端> ( ´・・)ノ(._.`) \n" +
                 " ___________ _   __\n" +
                 " ___________ _   __\n" +
                 "/  ___|  _  \\ | / /\n" +
                 "/  ___|  _  \\ | / /\n" +
                 "\\ `--.| | | | |/ / \n" +
                 "\\ `--.| | | | |/ / \n" +

+ 8 - 0
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/SmsServiceImpl.java

@@ -3,7 +3,9 @@ package com.zanxiang.game.module.sdk.service.impl;
 import cn.hutool.core.util.RandomUtil;
 import cn.hutool.core.util.RandomUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.zanxiang.game.module.base.ServerInfo;
 import com.zanxiang.game.module.base.pojo.enums.HttpStatusEnum;
 import com.zanxiang.game.module.base.pojo.enums.HttpStatusEnum;
+import com.zanxiang.game.module.base.rpc.IUserRpc;
 import com.zanxiang.game.module.mybatis.entity.Game;
 import com.zanxiang.game.module.mybatis.entity.Game;
 import com.zanxiang.game.module.mybatis.entity.User;
 import com.zanxiang.game.module.mybatis.entity.User;
 import com.zanxiang.game.module.sdk.constant.RedisKeyConstant;
 import com.zanxiang.game.module.sdk.constant.RedisKeyConstant;
@@ -24,6 +26,7 @@ import com.zanxiang.module.sms.service.impl.AliSmsService;
 import com.zanxiang.module.util.exception.BaseException;
 import com.zanxiang.module.util.exception.BaseException;
 import com.zanxiang.module.util.pojo.ResultVO;
 import com.zanxiang.module.util.pojo.ResultVO;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.dubbo.config.annotation.DubboReference;
 import org.apache.logging.log4j.util.Strings;
 import org.apache.logging.log4j.util.Strings;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
@@ -43,6 +46,9 @@ import java.util.Objects;
 @Service
 @Service
 public class SmsServiceImpl implements ISmsService {
 public class SmsServiceImpl implements ISmsService {
 
 
+    @DubboReference(providedBy = ServerInfo.SERVER_DUBBO_NAME)
+    private IUserRpc userRpc;
+
     @Autowired
     @Autowired
     private IUserService userService;
     private IUserService userService;
 
 
@@ -132,6 +138,8 @@ public class SmsServiceImpl implements ISmsService {
                 .set(User::getMobileBindTime, LocalDateTime.now())
                 .set(User::getMobileBindTime, LocalDateTime.now())
                 .set(User::getUpdateTime, LocalDateTime.now())
                 .set(User::getUpdateTime, LocalDateTime.now())
                 .eq(User::getId, userData.getUserId()));
                 .eq(User::getId, userData.getUserId()));
+        //通知游戏后台转端初始化
+        userRpc.appletToOther(userData.getUserId(), userData.getGameId(), param.getMobile());
         //返回结果
         //返回结果
         return this.buildResultMap(Boolean.TRUE, "绑定成功");
         return this.buildResultMap(Boolean.TRUE, "绑定成功");
     }
     }