소스 검색

feat : 接口对接口调试修改

bilingfeng 2 년 전
부모
커밋
ffe3adacd2

+ 2 - 154
game-module/game-common/src/main/java/com/zanxiang/common/enums/HttpStatusEnum.java

@@ -77,26 +77,11 @@ public enum HttpStatusEnum {
      */
     ACCOUNT_HALT(41108, "账号停用"),
 
-    /**
-     * 账户未绑定邮箱
-     */
-    ACCOUNT_NOT_BIND_EMAIL(41109, "账户未绑定邮箱"),
-
     /**
      * 账户未绑定手机
      */
     ACCOUNT_NOT_BIND_PHONE(41110, "账户未绑定手机"),
 
-    /**
-     * 用户ID不存在
-     */
-    UID_NOT_EXISTS(41111, "用户ID不存在"),
-
-    /**
-     * 用户ID非法
-     */
-    UID_INVALID(41112, "用户ID非法"),
-
     /**
      * 手机号请使用手机注册
      */
@@ -128,7 +113,7 @@ public enum HttpStatusEnum {
     PASSWORD_ERROR(41205, "密码错误"),
 
     /**
-     * 密码错误
+     * 密码错误
      */
     OLD_PASSWORD_ERROR(41206, "旧密码错误"),
 
@@ -142,11 +127,6 @@ public enum HttpStatusEnum {
      */
     PHONE_ERROR(41302, "手机号格式错误"),
 
-    /**
-     * 手机号或邮箱为空
-     */
-    PHONE_EMAIL_EMPTY(41303, "手机号或邮箱为空"),
-
     /**
      * 未绑定手机号
      */
@@ -190,43 +170,13 @@ public enum HttpStatusEnum {
     /**
      * 手机号绑定账号过多
      */
-    PHONE_BIND_TOOMUCH(41312, "手机号绑定账号过多"),
+    PHONE_BIND_TOO_MUCH(41312, "手机号绑定账号过多"),
 
     /**
      * 手机号错误
      */
     PHONE_NUM_ERROR(41313, "手机号错误"),
 
-    /**
-     * email为空
-     */
-    EMAIL_EMPTY(41351, "email为空"),
-
-    /**
-     * email格式错误
-     */
-    EMAIL_ERROR(41352, "email格式错误"),
-
-    /**
-     * 邮箱未绑定
-     */
-    EMAIL_NOT_BIND(41353, "邮箱未绑定"),
-
-    /**
-     * 邮箱已绑定
-     */
-    EMAIL_IS_BIND(41354, "邮箱已绑定"),
-
-    /**
-     * 验证码发送过于频繁
-     */
-    EMAIL_SEND_MORE(41355, "验证码发送过于频繁"),
-
-    /**
-     * 邮件发送失败
-     */
-    EMAIL_SEND_ERROR(41356, "邮件发送失败"),
-
     /**
      * 验证码错误
      */
@@ -252,87 +202,11 @@ public enum HttpStatusEnum {
      */
     CONFIG_ERROR(41699, "配置错误"),
 
-    /**
-     * 第三方登录失败
-     */
-    OAUTH_LOGIN_FAIL(41312, "第三方登录失败"),
-
-    /**
-     * 性别错误
-     */
-    GENDER_ERROR(41313, "性别错误"),
-
-    /**
-     * 第三方参数错误
-     */
-    OAUTH_TYPE_ERROR(41314, "第三方参数错误"),
-
     /**
      * 参数非法
      */
     INVALID_PARAMS(1000, "参数非法"),
 
-    /**
-     * 登陆已过期
-     */
-    LOGIN_IS_OUT(1002, "登陆已过期"),
-
-    /**
-     * 玩家已登录
-     */
-    HAS_LOGIN(1003, "玩家已登录"),
-
-    /**
-     * 积分不足
-     */
-    ITG_NOT_ENOUGH(44001, "积分不足"),
-
-    /**
-     * 昵称为空
-     */
-    NICKNAME_EMPTY(41401, "昵称为空"),
-
-    /**
-     * 昵称含敏感字
-     */
-    NICKNAME_SENSITIVE(41402, "昵称含敏感字"),
-
-    /**
-     * 昵称太短
-     */
-    NICKNAME_TOO_SHORT(41403, "昵称太短"),
-
-    /**
-     * 昵称太长
-     */
-    NICKNAME_TOO_LONG(41404, "昵称太长"),
-
-    /**
-     * 你不是渠道,不能进行此操作
-     */
-    YOU_ARE_NOT_AGENT(41405, "你不是渠道,不能进行此操作"),
-
-    /**
-     * 账号异常,不能进行此操作
-     */
-    MEM_ACCOUNT_ANOMALY(41406, "账号异常,不能进行此操作"),
-
-    /**
-     * 支付宝账号已绑定
-     */
-    ALIPAY_IS_BIND(41407, "支付宝账号已绑定"),
-
-    /**
-     * 请选择账号
-     */
-    SELECT_USERNAME_ERR(41407, "请选择账号"),
-
-    /**
-     * 玩家充值未达标
-     */
-    MEM_NOT_REACH_STAND(41407, "玩家充值未达标"),
-
-
     /**
      * 订单游戏id为空
      */
@@ -358,42 +232,16 @@ public enum HttpStatusEnum {
      */
     MDS_CONNECT_ERROR(41505, "米大师连接失败"),
 
-    /**
-     * 米大师生成签名失败
-     */
-    MAKE_SIGNATURE_ERROR(41506, "米大师生成签名失败"),
-
-
     /**
      * 获取配置异常
      */
     GET_CONFIG_ERROR(41507, "获取配置异常"),
 
-    /**
-     * 获取支付盒子失败
-     */
-    GET_PAY_BOX_ERROR(41508, "获取支付盒子失败"),
-
-    /**
-     * 应用状态为下线状态
-     */
-    PAY_APPLICATION_STATUS_IS_NO(41509, "应用状态为下线状态"),
-
-    /**
-     * 微信opendId为空
-     */
-    WEIXIN_OPEN_ID_NULL(41510, "微信opendId为空"),
-
     /**
      * 游戏用户未创建成功
      */
     GAME_USER_UN_CREATE(41511, "更新游戏角色时,检测为先创建游戏用户"),
 
-    /**
-     * 游戏不存在
-     */
-    GAME_UN_FUND(41512, "游戏不存在"),
-
     /**
      * 参数为空
      */

+ 4 - 4
game-module/game-sdk/src/main/java/com/zanxiang/sdk/adapter/WebHandlerAdapter.java

@@ -4,9 +4,9 @@ import com.zanxiang.common.enums.DeviceTypeEnum;
 import com.zanxiang.common.enums.HttpStatusEnum;
 import com.zanxiang.common.exception.CustomException;
 import com.zanxiang.common.utils.StringUtils;
-import com.zanxiang.mybatis.entity.GameKey;
+import com.zanxiang.mybatis.entity.GameExt;
 import com.zanxiang.sdk.annotation.UnSignCheck;
-import com.zanxiang.sdk.service.GameKeyService;
+import com.zanxiang.sdk.service.GameExtService;
 import com.zanxiang.sdk.util.SignUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.logging.log4j.util.Strings;
@@ -31,7 +31,7 @@ import java.util.Objects;
 public class WebHandlerAdapter implements HandlerInterceptor {
 
     @Resource
-    private GameKeyService gameKeyService;
+    private GameExtService gameExtService;
 
     @Override
     public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
@@ -63,7 +63,7 @@ public class WebHandlerAdapter implements HandlerInterceptor {
             throw new CustomException(HttpStatusEnum.INVALID_PARAMS);
         }
         //签名验证
-        GameKey gameKey = gameKeyService.getByGameId(Long.valueOf(gameId));
+        GameExt gameKey = gameExtService.getByGameId(Long.valueOf(gameId));
         if (gameKey == null || Strings.isBlank(gameKey.getAppKey())) {
             log.error("非法参数, 游戏id对应的前端密钥appKey不存在");
             throw new CustomException(HttpStatusEnum.INVALID_PARAMS);

+ 2 - 0
game-module/game-sdk/src/main/java/com/zanxiang/sdk/controller/LoginController.java

@@ -69,6 +69,8 @@ public class LoginController {
         return ResultVO.ok();
     }
 
+    //------------------------- QQ和微信的授权登录接口 -------------------------
+
 //    @ApiOperation(value = "用户QQ授权登录")
 //    @GetMapping("/register/login/qq")
 //    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = UserLoginVO.class)})

+ 8 - 0
game-module/game-sdk/src/main/java/com/zanxiang/sdk/controller/UserController.java

@@ -3,6 +3,7 @@ package com.zanxiang.sdk.controller;
 import com.zanxiang.common.domain.ResultVO;
 import com.zanxiang.sdk.annotation.ValidLogin;
 import com.zanxiang.sdk.domain.params.*;
+import com.zanxiang.sdk.domain.vo.CustomerVO;
 import com.zanxiang.sdk.domain.vo.UserLoginVO;
 import com.zanxiang.sdk.service.UserCardService;
 import com.zanxiang.sdk.service.UserService;
@@ -68,6 +69,13 @@ public class UserController {
         return userService.getUserDetail(userDetailParam, userData);
     }
 
+    @ApiOperation(value = "获取客服信息")
+    @PostMapping("/get/customer")
+    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = CustomerVO.class)})
+    public ResultVO<CustomerVO> getUserCustomer(UserData userData) {
+        return ResultVO.ok(userService.getUserCustomer(userData));
+    }
+
     @ApiOperation(value = "上传角色信息")
     @PostMapping("/update/game/role")
     @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = UserLoginVO.class)})

+ 43 - 0
game-module/game-sdk/src/main/java/com/zanxiang/sdk/domain/vo/CustomerVO.java

@@ -0,0 +1,43 @@
+package com.zanxiang.sdk.domain.vo;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @author : lingfeng
+ * @time : 2022-10-03
+ * @description : 客服信息
+ */
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class CustomerVO {
+
+    /**
+     * 客服手机
+     */
+    private String customerPhone;
+
+    /**
+     * 客服QQ
+     */
+    private String customerQq;
+
+    /**
+     * 公众号id
+     */
+    private String mpAppId;
+
+    /**
+     * 公众号名字
+     */
+    private String mpAppName;
+
+    /**
+     * 公众号二维码图片地址
+     */
+    private String mpCode;
+}

+ 3 - 3
game-module/game-sdk/src/main/java/com/zanxiang/sdk/service/GameKeyService.java → game-module/game-sdk/src/main/java/com/zanxiang/sdk/service/GameExtService.java

@@ -1,14 +1,14 @@
 package com.zanxiang.sdk.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
-import com.zanxiang.mybatis.entity.GameKey;
+import com.zanxiang.mybatis.entity.GameExt;
 
 /**
  * @author : lingfeng
  * @time : 2022-09-23
  * @description : 游戏密钥
  */
-public interface GameKeyService extends IService<GameKey> {
+public interface GameExtService extends IService<GameExt> {
 
     /**
      * 根据游戏id查询密钥
@@ -16,5 +16,5 @@ public interface GameKeyService extends IService<GameKey> {
      * @param gameId : 游戏id
      * @return : 返回游戏密钥
      */
-    GameKey getByGameId(Long gameId);
+    GameExt getByGameId(Long gameId);
 }

+ 8 - 8
game-module/game-sdk/src/main/java/com/zanxiang/sdk/service/Impl/GameKeyServiceImpl.java → game-module/game-sdk/src/main/java/com/zanxiang/sdk/service/Impl/GameExtServiceImpl.java

@@ -3,10 +3,10 @@ package com.zanxiang.sdk.service.Impl;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.zanxiang.common.enums.ExpireTimeEnum;
-import com.zanxiang.mybatis.entity.GameKey;
-import com.zanxiang.mybatis.mapper.GameKeyMapper;
+import com.zanxiang.mybatis.entity.GameExt;
+import com.zanxiang.mybatis.mapper.GameExtMapper;
 import com.zanxiang.sdk.constant.RedisKeyConstant;
-import com.zanxiang.sdk.service.GameKeyService;
+import com.zanxiang.sdk.service.GameExtService;
 import com.zanxiang.sdk.util.RedisUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -19,10 +19,10 @@ import org.springframework.stereotype.Service;
  */
 @Slf4j
 @Service
-public class GameKeyServiceImpl extends ServiceImpl<GameKeyMapper, GameKey> implements GameKeyService {
+public class GameExtServiceImpl extends ServiceImpl<GameExtMapper, GameExt> implements GameExtService {
 
     @Autowired
-    private RedisUtil<GameKey> redisUtil;
+    private RedisUtil<GameExt> redisUtil;
 
     /**
      * 根据游戏id查询密钥
@@ -31,11 +31,11 @@ public class GameKeyServiceImpl extends ServiceImpl<GameKeyMapper, GameKey> impl
      * @return : 返回游戏密钥
      */
     @Override
-    public GameKey getByGameId(Long gameId) {
+    public GameExt getByGameId(Long gameId) {
         //查询缓存
-        GameKey gameKey = redisUtil.getCache(this.getGameKey(gameId));
+        GameExt gameKey = redisUtil.getCache(this.getGameKey(gameId));
         if (gameKey == null) {
-            gameKey = this.getOne(new LambdaQueryWrapper<GameKey>().eq(GameKey::getGameId, gameId));
+            gameKey = this.getOne(new LambdaQueryWrapper<GameExt>().eq(GameExt::getGameId, gameId));
         }
         if (gameKey != null) {
             redisUtil.setCache(this.getGameKey(gameId), gameKey, ExpireTimeEnum.ONE_DAY.getTime());

+ 23 - 2
game-module/game-sdk/src/main/java/com/zanxiang/sdk/service/Impl/UserServiceImpl.java

@@ -7,13 +7,15 @@ import com.zanxiang.common.domain.ResultVO;
 import com.zanxiang.common.enums.HttpStatusEnum;
 import com.zanxiang.common.enums.SmsTypeEnum;
 import com.zanxiang.common.utils.bean.BeanUtils;
+import com.zanxiang.mybatis.entity.GameExt;
 import com.zanxiang.mybatis.entity.User;
 import com.zanxiang.mybatis.mapper.UserMapper;
 import com.zanxiang.sdk.domain.dto.UserDTO;
 import com.zanxiang.sdk.domain.dto.UserTokenDTO;
 import com.zanxiang.sdk.domain.params.*;
+import com.zanxiang.sdk.domain.vo.CustomerVO;
 import com.zanxiang.sdk.domain.vo.UserVO;
-import com.zanxiang.sdk.service.GameService;
+import com.zanxiang.sdk.service.GameExtService;
 import com.zanxiang.sdk.service.SmsService;
 import com.zanxiang.sdk.service.UserService;
 import com.zanxiang.sdk.service.UserTokenService;
@@ -40,7 +42,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
     private UserTokenService userTokenService;
 
     @Autowired
-    private GameService gameService;
+    private GameExtService gameExtService;
 
     @Autowired
     private SmsService smsService;
@@ -180,6 +182,25 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
         return new ResultVO<>(HttpStatusEnum.SUCCESS, userVO);
     }
 
+    /**
+     * 用户获取游戏客服信息
+     *
+     * @param userData : userData
+     * @return : 返回用户信息
+     */
+    @Override
+    public CustomerVO getUserCustomer(UserData userData) {
+        Long gameId = userData.getGameId();
+        GameExt gameExt = gameExtService.getByGameId(gameId);
+        return CustomerVO.builder()
+                .customerPhone(gameExt.getCustomerPhone())
+                .customerQq(gameExt.getCustomerQq())
+                .mpAppId(gameExt.getMpAppId())
+                .mpAppName(gameExt.getMpAppName())
+                .mpCode(gameExt.getMpCode())
+                .build();
+    }
+
     /**
      * 根据手机号获取用户信息
      *

+ 14 - 11
game-module/game-sdk/src/main/java/com/zanxiang/sdk/service/Impl/UserTokenServiceImpl.java

@@ -11,12 +11,12 @@ import com.zanxiang.common.text.UUID;
 import com.zanxiang.common.utils.DateUtils;
 import com.zanxiang.common.utils.MD5Util;
 import com.zanxiang.common.utils.bean.BeanUtils;
-import com.zanxiang.mybatis.entity.GameKey;
+import com.zanxiang.mybatis.entity.GameExt;
 import com.zanxiang.mybatis.entity.UserToken;
 import com.zanxiang.mybatis.mapper.UserTokenMapper;
 import com.zanxiang.sdk.constant.RedisKeyConstant;
 import com.zanxiang.sdk.domain.dto.UserTokenDTO;
-import com.zanxiang.sdk.service.GameKeyService;
+import com.zanxiang.sdk.service.GameExtService;
 import com.zanxiang.sdk.service.UserTokenService;
 import com.zanxiang.sdk.util.RedisUtil;
 import com.zanxiang.sdk.util.SignUtil;
@@ -43,7 +43,7 @@ public class UserTokenServiceImpl extends ServiceImpl<UserTokenMapper, UserToken
     private RedisUtil<UserToken> redisUtil;
 
     @Autowired
-    private GameKeyService gameKeyService;
+    private GameExtService gameExtService;
 
     /**
      * 登录凭证验证
@@ -57,14 +57,21 @@ public class UserTokenServiceImpl extends ServiceImpl<UserTokenMapper, UserToken
     @Override
     public ResultVO<Long> userTokenCheck(Long gameId, Long userId, String token, String sign) {
         //查询登录签名
-        GameKey gameKey = gameKeyService.getByGameId(gameId);
+        GameExt gameKey = gameExtService.getByGameId(gameId);
         if (gameKey == null || Strings.isBlank(gameKey.getLoginKey())) {
-            return ResultVO.ok(-3, "游戏登录密钥不存在");
+            return ResultVO.ok(-3, "验证失败");
+        }
+        //查询token是否存在
+        UserToken userToken = super.getOne(new LambdaQueryWrapper<UserToken>()
+                .eq(UserToken::getToken, token)
+                .eq(UserToken::getUserId, userId));
+        if (userToken == null) {
+            return ResultVO.ok(-3, "验证失败");
         }
         //登录密钥
         String loginKey = gameKey.getLoginKey();
         //计算用户签名
-        String sb = "loginKey=" + loginKey + "&" + "gameId=" + gameId + "&" + "userId=" + userId + "&" + "token=" + token;
+        String sb = "loginKey=" + loginKey + "&gameId=" + gameId + "&userId=" + userId + "&token=" + token;
         String mySign;
         try {
             mySign = SignUtil.MD5(sb);
@@ -75,11 +82,7 @@ public class UserTokenServiceImpl extends ServiceImpl<UserTokenMapper, UserToken
         if (!Objects.equals(mySign, sign)) {
             return ResultVO.ok(-2, "签名错误");
         }
-        //查询token是否存在
-        if (Objects.equals(mySign, sign)) {
-            return ResultVO.ok(1, "验证成功", userId);
-        }
-        return ResultVO.ok(-2, "签名错误");
+        return ResultVO.ok(1, "验证成功", userId);
     }
 
     /**

+ 9 - 0
game-module/game-sdk/src/main/java/com/zanxiang/sdk/service/UserService.java

@@ -5,6 +5,7 @@ import com.zanxiang.common.domain.ResultVO;
 import com.zanxiang.mybatis.entity.User;
 import com.zanxiang.sdk.domain.dto.UserDTO;
 import com.zanxiang.sdk.domain.params.*;
+import com.zanxiang.sdk.domain.vo.CustomerVO;
 import com.zanxiang.sdk.domain.vo.UserVO;
 
 /**
@@ -49,6 +50,14 @@ public interface UserService extends IService<User> {
      */
     ResultVO<UserVO> getUserDetail(UserDetailParam userDetailParam, UserData userData);
 
+    /**
+     * 用户获取游戏客服信息
+     *
+     * @param userData : userData
+     * @return : 返回用户信息
+     */
+    CustomerVO getUserCustomer(UserData userData);
+
     /**
      * 根据手机号获取用户信息
      *