Explorar el Código

fix : SDK对接调试修改

bilingfeng hace 1 año
padre
commit
4deda45af1

+ 3 - 3
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/controller/InitController.java

@@ -2,7 +2,7 @@ package com.zanxiang.game.module.sdk.controller;
 
 import com.zanxiang.game.module.sdk.annotation.UnSignCheck;
 import com.zanxiang.game.module.sdk.pojo.param.UserData;
-import com.zanxiang.game.module.sdk.pojo.vo.GameAppletVO;
+import com.zanxiang.game.module.sdk.pojo.vo.GameInitVO;
 import com.zanxiang.game.module.sdk.service.IGameAppletService;
 import com.zanxiang.module.util.pojo.ResultVO;
 import io.swagger.annotations.Api;
@@ -30,8 +30,8 @@ public class InitController {
     @UnSignCheck
     @ApiOperation(value = "微信小游戏sdk初始化")
     @PostMapping("/applet")
-    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = GameAppletVO.class)})
-    public ResultVO<GameAppletVO> gameAppletInit(UserData userData) {
+    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = GameInitVO.class)})
+    public ResultVO<GameInitVO> gameAppletInit(UserData userData) {
         return ResultVO.ok(gameAppletService.gameAppletInit(userData));
     }
 }

+ 0 - 32
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/pojo/vo/GameAppletVO.java

@@ -1,32 +0,0 @@
-package com.zanxiang.game.module.sdk.pojo.vo;
-
-import io.swagger.annotations.ApiModelProperty;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-/**
- * @author : lingfeng
- * @time : 2023-01-03
- * @description : 微信小游戏初始化
- */
-@Data
-@Builder
-@AllArgsConstructor
-@NoArgsConstructor
-public class GameAppletVO {
-
-    /**
-     * 应用appId
-     */
-    @ApiModelProperty(notes = "应用appId")
-    private String appId;
-
-    /**
-     * 是否投放
-     */
-    @ApiModelProperty(notes = "是否投放")
-    private Boolean isPut;
-
-}

+ 6 - 0
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/pojo/vo/GameInitVO.java

@@ -1,7 +1,10 @@
 package com.zanxiang.game.module.sdk.pojo.vo;
 
 import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
 import lombok.Data;
+import lombok.NoArgsConstructor;
 
 /**
  * @author : lingfeng
@@ -9,6 +12,9 @@ import lombok.Data;
  * @description : 游戏初始化
  */
 @Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
 public class GameInitVO {
 
     /**

+ 3 - 3
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/IGameAppletService.java

@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.zanxiang.game.module.mybatis.entity.GameApplet;
 import com.zanxiang.game.module.sdk.pojo.dto.GameAppletDTO;
 import com.zanxiang.game.module.sdk.pojo.param.UserData;
-import com.zanxiang.game.module.sdk.pojo.vo.GameAppletVO;
+import com.zanxiang.game.module.sdk.pojo.vo.GameInitVO;
 
 /**
  * @author : lingfeng
@@ -58,7 +58,7 @@ public interface IGameAppletService extends IService<GameApplet> {
      * 微信小游戏初始化获取信息
      *
      * @param userData : 用户信息
-     * @return {@link GameAppletVO}
+     * @return {@link GameInitVO}
      */
-    GameAppletVO gameAppletInit(UserData userData);
+    GameInitVO gameAppletInit(UserData userData);
 }

+ 14 - 5
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/GameAppletServiceImpl.java

@@ -10,7 +10,7 @@ import com.zanxiang.game.module.mybatis.mapper.GameAppletMapper;
 import com.zanxiang.game.module.sdk.enums.OrderStateEnum;
 import com.zanxiang.game.module.sdk.pojo.dto.*;
 import com.zanxiang.game.module.sdk.pojo.param.UserData;
-import com.zanxiang.game.module.sdk.pojo.vo.GameAppletVO;
+import com.zanxiang.game.module.sdk.pojo.vo.GameInitVO;
 import com.zanxiang.game.module.sdk.service.*;
 import com.zanxiang.game.module.sdk.service.api.WxApiService;
 import com.zanxiang.game.module.sdk.util.SignUtil;
@@ -184,13 +184,22 @@ public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApp
     }
 
     @Override
-    public GameAppletVO gameAppletInit(UserData userData) {
+    public GameInitVO gameAppletInit(UserData userData) {
+        //游戏
+        Game game = gameService.getById(userData.getGameId());
+        if (game == null) {
+            throw new BaseException("参数错误, 游戏信息不存在");
+        }
+        //游戏应用信息
         GameApplet gameApplet = super.getOne(new LambdaQueryWrapper<GameApplet>()
                 .eq(GameApplet::getGameId, userData.getGameId()));
-        Game game = gameService.getById(userData.getGameId());
-        return GameAppletVO.builder()
+        //构造初始化信息
+        return GameInitVO.builder()
                 .appId(gameApplet == null ? null : gameApplet.getAppId())
-                .isPut(game.getParentId() == null)
+                .gameName(game.getName())
+                .isPut(game.getIsPut())
+                .h5GameUrl(game.getH5GameUrl())
+                .h5LoginLogo(game.getH5LoginLogo())
                 .build();
     }
 }

+ 4 - 4
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/LoginServiceImpl.java

@@ -105,6 +105,10 @@ public class LoginServiceImpl implements IRegisterLoginService {
         //根据openId查询用户
         User user = userService.getOne(new LambdaQueryWrapper<User>()
                 .eq(User::getGameId, userData.getGameId()).eq(User::getOpenId, openId));
+        //账号停用, 返回登录失败
+        if (user != null && Objects.equals(BanStatusEnum.BAN_STATUS.getStatus(), user.getStatus())) {
+            return ResultVO.fail(HttpStatusEnum.ACCOUNT_HALT.getMsg());
+        }
         //已注册
         if (user != null) {
             //更新用户sessionKey
@@ -115,10 +119,6 @@ public class LoginServiceImpl implements IRegisterLoginService {
             }
             //渠道更新和回传判断
             agentService.userAgentUpdate(user, userData.getChannel());
-            //判断账号是否停用
-            if (Objects.equals(BanStatusEnum.BAN_STATUS.getStatus(), user.getStatus())) {
-                return ResultVO.fail(HttpStatusEnum.ACCOUNT_HALT.getMsg());
-            }
             //返回登录信息
             return ResultVO.ok(this.createUserLoginVO(user, userData));
         }