bilingfeng 1 рік тому
батько
коміт
2154c4134f

+ 1 - 1
game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/enums/HttpStatusEnum.java

@@ -35,7 +35,7 @@ public enum HttpStatusEnum {
     /**
      * 请先登录
      */
-    USER_NO_LOGIN(40400, "请登录"),
+    USER_NO_LOGIN(40400, "登录信息已失效, 重新登录"),
 
     /**
      * 用户名为空

+ 5 - 0
game-module/game-module-mybatis/src/main/java/com/zanxiang/game/module/mybatis/entity/GameExt.java

@@ -69,6 +69,11 @@ public class GameExt implements Serializable {
      */
     private Boolean adCallBackSwitch;
 
+    /**
+     * 小游戏壳包控制开关
+     */
+    private Boolean appletShellSwitch;
+
     /**
      * 客服手机
      */

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

@@ -12,6 +12,7 @@ import io.swagger.annotations.ApiResponses;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 /**
@@ -28,10 +29,18 @@ public class InitController {
     private IGameAppletService gameAppletService;
 
     @UnSignCheck
-    @ApiOperation(value = "微信小游戏sdk初始化")
+    @ApiOperation(value = "(H5和微信小游戏)SDK参数初始化")
     @PostMapping("/applet")
     @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = GameInitVO.class)})
-    public ResultVO<GameInitVO> gameAppletInit(UserData userData) {
-        return ResultVO.ok(gameAppletService.gameAppletInit(userData));
+    public ResultVO<GameInitVO> h5AndAppletInit(UserData userData) {
+        return ResultVO.ok(gameAppletService.h5AndAppletInit(userData));
+    }
+
+    @UnSignCheck
+    @ApiOperation(value = "微信小游戏壳包控制开关")
+    @PostMapping("/shell/switch")
+    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = Boolean.class)})
+    public ResultVO<Boolean> appletShellSwitch(@RequestParam String appId) {
+        return ResultVO.ok(gameAppletService.appletShellSwitch(appId));
     }
 }

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

@@ -29,6 +29,12 @@ public class GameInitVO {
     @ApiModelProperty(notes = "游戏应用(小游戏/公众号)appId")
     private String appId;
 
+    /**
+     * 前端appKey
+     */
+    @ApiModelProperty(notes = "前端appKey")
+    private String appKey;
+
     /**
      * H5游戏是否使用应用授权登录
      */

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

@@ -33,6 +33,7 @@ public interface IGameAppletService extends IService<GameApplet> {
      * @param signature 签名
      * @param timestamp 时间戳
      * @param nonce     现时标志
+     * @param postData  post数据
      * @return {@link String}
      * @throws Exception 异常
      */
@@ -60,5 +61,13 @@ public interface IGameAppletService extends IService<GameApplet> {
      * @param userData : 用户信息
      * @return {@link GameInitVO}
      */
-    GameInitVO gameAppletInit(UserData userData);
+    GameInitVO h5AndAppletInit(UserData userData);
+
+    /**
+     * 小游戏壳包控制开关
+     *
+     * @param appId 应用程序id
+     * @return boolean
+     */
+    boolean appletShellSwitch(String appId);
 }

+ 16 - 1
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/GameAppletServiceImpl.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.zanxiang.game.module.base.pojo.enums.HttpStatusEnum;
 import com.zanxiang.game.module.mybatis.entity.Game;
 import com.zanxiang.game.module.mybatis.entity.GameApplet;
+import com.zanxiang.game.module.mybatis.entity.GameExt;
 import com.zanxiang.game.module.mybatis.entity.Order;
 import com.zanxiang.game.module.mybatis.mapper.GameAppletMapper;
 import com.zanxiang.game.module.sdk.enums.OrderStateEnum;
@@ -61,6 +62,9 @@ public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApp
     @Autowired
     private IGameService gameService;
 
+    @Autowired
+    private IGameExtService gameExtService;
+
     @Value("${payConfig.wxPay.customH5Url}")
     private String customH5Url;
 
@@ -184,7 +188,7 @@ public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApp
     }
 
     @Override
-    public GameInitVO gameAppletInit(UserData userData) {
+    public GameInitVO h5AndAppletInit(UserData userData) {
         //游戏
         Game game = gameService.getById(userData.getGameId());
         if (game == null) {
@@ -193,13 +197,24 @@ public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApp
         //游戏应用信息
         GameApplet gameApplet = super.getOne(new LambdaQueryWrapper<GameApplet>()
                 .eq(GameApplet::getGameId, userData.getGameId()));
+        GameExt gameExt = gameExtService.getByGameId(userData.getGameId());
         //构造初始化信息
         return GameInitVO.builder()
                 .appId(gameApplet == null ? null : gameApplet.getAppId())
+                .appKey(gameExt == null ? null : gameExt.getAppKey())
                 .gameName(game.getName())
                 .isPut(game.getIsPut())
                 .h5GameUrl(game.getH5GameUrl())
                 .h5LoginLogo(game.getH5LoginLogo())
                 .build();
     }
+
+    @Override
+    public boolean appletShellSwitch(String appId) {
+        GameExt gameExt = gameExtService.getByGameAppId(appId);
+        if (gameExt == null || gameExt.getAppletShellSwitch() == null) {
+            return false;
+        }
+        return gameExt.getAppletShellSwitch();
+    }
 }

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

@@ -105,17 +105,16 @@ 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) {
+            //账号停用, 返回登录失败
+            if (Objects.equals(BanStatusEnum.BAN_STATUS.getStatus(), user.getStatus())) {
+                return ResultVO.fail(HttpStatusEnum.ACCOUNT_HALT.getMsg());
+            }
             //更新用户sessionKey
             if (Strings.isNotBlank(sessionKey)) {
                 userService.update(new LambdaUpdateWrapper<User>()
-                        .set(User::getSessionKey, sessionKey)
-                        .eq(User::getId, user.getId()));
+                        .set(User::getSessionKey, sessionKey).eq(User::getId, user.getId()));
             }
             //渠道更新和回传判断
             agentService.userAgentUpdate(user, userData.getChannel());
@@ -153,8 +152,6 @@ public class LoginServiceImpl implements IRegisterLoginService {
                 user = userService.getOne(new LambdaQueryWrapper<User>()
                         .eq(User::getGameId, userData.getGameId()).eq(User::getUsername, username));
             }
-            //渠道更新和回传判断
-            agentService.userAgentUpdate(user, userData.getChannel());
             //用户信息不存在
             if (user == null) {
                 return ResultVO.fail(HttpStatusEnum.USERNAME_OR_PASSWORD_ERR.getMsg());
@@ -167,6 +164,8 @@ public class LoginServiceImpl implements IRegisterLoginService {
             if (!Objects.equals(RegisterUtil.cmfPassword(password), user.getPassword())) {
                 return ResultVO.fail(HttpStatusEnum.USERNAME_OR_PASSWORD_ERR.getMsg());
             }
+            //渠道更新和回传判断
+            agentService.userAgentUpdate(user, userData.getChannel());
             //返回登录信息
             return ResultVO.ok(this.createUserLoginVO(user, userData));
         }
@@ -201,12 +200,12 @@ public class LoginServiceImpl implements IRegisterLoginService {
                 .eq(User::getGameId, userData.getGameId()).eq(User::getMobile, mobile));
         //用户信息存在
         if (user != null) {
-            //渠道更新和回传判断
-            agentService.userAgentUpdate(user, userData.getChannel());
             //判断账号是否停用
             if (Objects.equals(BanStatusEnum.BAN_STATUS.getStatus(), user.getStatus())) {
                 return ResultVO.fail(HttpStatusEnum.ACCOUNT_HALT.getMsg());
             }
+            //渠道更新和回传判断
+            agentService.userAgentUpdate(user, userData.getChannel());
             //返回登录信息
             return ResultVO.ok(this.createUserLoginVO(user, userData));
         }