Parcourir la source

Merge remote-tracking branch 'origin/package' into package

shishaosong il y a 1 an
Parent
commit
cac3ac9d23
35 fichiers modifiés avec 420 ajouts et 243 suppressions
  1. 100 0
      game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/handler/GlobalExceptionHandler.java
  2. 9 9
      game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/enums/HttpStatusEnum.java
  3. 19 1
      game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/enums/PayDeviceEnum.java
  4. 1 1
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/ManageApplication.java
  5. 12 0
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/controller/GameController.java
  6. 2 2
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/dto/GameAppletConfigDTO.java
  7. 17 97
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/dto/GameDTO.java
  8. 6 0
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/vo/UserVO.java
  9. 8 0
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/IGameAppletService.java
  10. 43 15
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameAppletServiceImpl.java
  11. 1 1
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameUserRoleServiceImpl.java
  12. 5 2
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameUserServiceImpl.java
  13. 4 2
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/OrderServiceImpl.java
  14. 2 1
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/UserCardServiceImpl.java
  15. 4 2
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/UserServiceImpl.java
  16. 1 1
      game-module/game-module-mybatis/src/main/java/com/zanxiang/game/module/mybatis/entity/GameApplet.java
  17. 5 0
      game-module/game-module-mybatis/src/main/java/com/zanxiang/game/module/mybatis/entity/GameExt.java
  18. 12 3
      game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/controller/InitController.java
  19. 10 4
      game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/controller/PayController.java
  20. 5 0
      game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/pojo/dto/ProductPayParamDTO.java
  21. 6 0
      game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/pojo/vo/GameInitVO.java
  22. 10 1
      game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/IGameAppletService.java
  23. 2 1
      game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/IOrderPayService.java
  24. 3 1
      game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/IOrderService.java
  25. 8 2
      game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/AgentServiceImpl.java
  26. 7 0
      game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/CallBackServiceImpl.java
  27. 16 1
      game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/GameAppletServiceImpl.java
  28. 9 10
      game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/LoginServiceImpl.java
  29. 57 43
      game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/OrderPayServiceImpl.java
  30. 8 21
      game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/OrderServiceImpl.java
  31. 9 0
      game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/UserTokenServiceImpl.java
  32. 1 2
      game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/pay/AliPayService.java
  33. 1 1
      game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/pay/PayBaseService.java
  34. 14 16
      game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/pay/WxPayService.java
  35. 3 3
      game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/util/RegisterUtil.java

+ 100 - 0
game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/handler/GlobalExceptionHandler.java

@@ -0,0 +1,100 @@
+package com.zanxiang.game.back.serve.handler;
+
+import com.zanxiang.erp.security.exception.NoPermissionException;
+import com.zanxiang.module.util.DateUtil;
+import com.zanxiang.module.util.exception.BaseException;
+import com.zanxiang.module.util.pojo.ResultVO;
+import com.zanxiang.module.web.util.ServletUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.converter.HttpMessageNotReadableException;
+import org.springframework.validation.BindException;
+import org.springframework.web.HttpRequestMethodNotSupportedException;
+import org.springframework.web.bind.MethodArgumentNotValidException;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
+import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
+
+import java.time.LocalDateTime;
+
+/**
+ * 全局异常代理
+ *
+ * @author bilingfeng
+ */
+@Slf4j
+@RestControllerAdvice
+public class GlobalExceptionHandler {
+
+    /**
+     * 业务异常
+     */
+    @ExceptionHandler(BaseException.class)
+    public ResultVO<?> baseException(BaseException e) {
+        return ResultVO.fail(e.getMessage());
+    }
+
+    /**
+     * http method错误
+     *
+     * @param e
+     * @return
+     */
+    @ExceptionHandler(HttpRequestMethodNotSupportedException.class)
+    public ResultVO<?> methodNotSupportedException(HttpRequestMethodNotSupportedException e) {
+        log.error("URL:{}, 请求 method:{}, 支持的 method:{}", ServletUtil.getRequest().getRequestURL(), ServletUtil.getRequest().getMethod(), e.getSupportedMethods());
+        return ResultVO.fail("http method错误!");
+    }
+
+    /**
+     * 自定义参数校验错误
+     */
+    @ExceptionHandler(BindException.class)
+    public ResultVO<?> validatedBindException(BindException e) {
+        String message = e.getAllErrors().get(0).getDefaultMessage();
+        return ResultVO.fail(message);
+    }
+
+    /**
+     * 自定义参数校验错误
+     */
+    @ExceptionHandler(MethodArgumentNotValidException.class)
+    public ResultVO<?> validExceptionHandler(MethodArgumentNotValidException e) {
+        String message = e.getBindingResult().getFieldError().getDefaultMessage();
+        return ResultVO.fail(message);
+    }
+
+    /**
+     * 自定义参数校验错误
+     */
+    @ExceptionHandler(HttpMessageNotReadableException.class)
+    public ResultVO<?> validExceptionHandler(HttpMessageNotReadableException e) {
+        log.error(e.getMessage(), e);
+        return ResultVO.fail("参数异常,请勿非法操作");
+    }
+
+    /**
+     * 参数类型不匹配导致转换异常
+     *
+     * @param e
+     * @return
+     */
+    @ExceptionHandler(MethodArgumentTypeMismatchException.class)
+    public ResultVO<?> mismatchErrorHandler(MethodArgumentTypeMismatchException e) {
+        log.error("方法:{},字段:{},参数:{},错误信息:{}", e.getParameter().getMethod(), e.getName(), e.getValue(), e.getMessage());
+        return ResultVO.fail("请求参数异常,请勿非法操作");
+    }
+
+    /**
+     * 权限异常
+     */
+    @ExceptionHandler(NoPermissionException.class)
+    public ResultVO<?> preAuthorizeException(NoPermissionException e) {
+        return ResultVO.fail("没有权限,请联系管理员授权");
+    }
+
+    @ExceptionHandler(Exception.class)
+    public ResultVO<?> handleException(Exception e) {
+        log.error(e.getMessage(), e);
+        return ResultVO.fail(DateUtil.formatLocalDateTime(LocalDateTime.now()) + ": 服务异常,请联系管理员");
+    }
+}

+ 9 - 9
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, "登录信息已失效, 重新登录"),
 
     /**
      * 用户名为空
@@ -65,27 +65,27 @@ public enum HttpStatusEnum {
     /**
      * 用户名太短
      */
-    USERNAME_TOO_SHORT(41105, "用户名太短"),
+    USERNAME_TOO_SHORT(41105, "用户名太短, 用户名需数字与字母组合,长度为:8-16"),
 
     /**
      * 用户名太长
      */
-    USERNAME_TOO_LONG(41106, "用户名太长"),
+    USERNAME_TOO_LONG(41106, "用户名太长, 用户名需数字与字母组合,长度为:8-16"),
 
     /**
      * 用户名必须为数字字母组合
      */
-    USERNAME_BAD_CHAR(41107, "用户名必须为数字字母组合"),
+    USERNAME_BAD_CHAR(41107, "用户名必须为数字字母组合,长度为:8-16"),
 
     /**
      * 账号停用
      */
-    ACCOUNT_HALT(41108, "账号停用"),
+    ACCOUNT_HALT(41108, "账号停用, 请联系客服"),
 
     /**
      * ip封禁
      */
-    IP_HALT(41109, "ip封禁"),
+    IP_HALT(41109, "ip封禁, 请联系客服"),
 
     /**
      * 账户未绑定手机
@@ -105,17 +105,17 @@ public enum HttpStatusEnum {
     /**
      * 密码必须为数字字母组合
      */
-    PASSWORD_BAD_CHAR(41202, "密码必须为数字字母组合"),
+    PASSWORD_BAD_CHAR(41202, "密码必须为数字字母组合,长度为:6-24"),
 
     /**
      * 密码太长
      */
-    PASSWORD_TOO_LONG(41203, "密码太长"),
+    PASSWORD_TOO_LONG(41203, "密码太长, 密码需数字与字母组合,长度为:6-24"),
 
     /**
      * 密码太短
      */
-    PASSWORD_TOO_SHORT(41204, "密码太短"),
+    PASSWORD_TOO_SHORT(41204, "密码太短, 密码需数字与字母组合,长度为:6-24"),
 
     /**
      * 密码错误

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

@@ -4,6 +4,8 @@ import lombok.AllArgsConstructor;
 import lombok.Getter;
 import org.apache.logging.log4j.util.Strings;
 
+import java.util.Arrays;
+import java.util.List;
 import java.util.Objects;
 
 /**
@@ -44,7 +46,12 @@ public enum PayDeviceEnum {
     /**
      * 客服支付
      */
-    CUSTOM_PAY(6L, "CUSTOM_PAY", "客服支付");
+    CUSTOM_PAY(6L, "CUSTOM_PAY", "客服支付"),
+
+    /**
+     * 公众号支付
+     */
+    MP_PAY(7L, "MP_PAY", "公众号支付");
 
     /**
      * 支付方式id
@@ -78,4 +85,15 @@ public enum PayDeviceEnum {
         }
         return Strings.EMPTY;
     }
+
+    /**
+     * 获取特殊的支付类型(预下单在获取支付参数)
+     *
+     * @return {@link List}<{@link Long}>
+     */
+    public static List<Long> getByPayWayIdList() {
+        return Arrays.asList(PayDeviceEnum.APPLET_PAY.getPayDeviceId(),
+                PayDeviceEnum.CUSTOM_PAY.getPayDeviceId(),
+                PayDeviceEnum.MP_PAY.getPayDeviceId());
+    }
 }

+ 1 - 1
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/ManageApplication.java

@@ -21,7 +21,7 @@ public class ManageApplication {
 
     public static void main(String[] args) {
         SpringApplication.run(ManageApplication.class, args);
-        System.out.println("赞象Manage服务启动成功003 ( ´・・)ノ(._.`) \n" +
+        System.out.println("赞象Manage服务启动成功0043 ( ´・・)ノ(._.`) \n" +
                 "___  ___  ___   _   _   ___  _____  _____ \n" +
                 "|  \\/  | / _ \\ | \\ | | / _ \\|  __ \\|  ___|\n" +
                 "| .  . |/ /_\\ \\|  \\| |/ /_\\ \\ |  \\/| |__  \n" +

+ 12 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/controller/GameController.java

@@ -5,6 +5,7 @@ import com.zanxiang.erp.security.annotation.PreAuthorize;
 import com.zanxiang.game.module.manage.pojo.params.GameAddParam;
 import com.zanxiang.game.module.manage.pojo.params.GameListParam;
 import com.zanxiang.game.module.manage.pojo.vo.GameListVO;
+import com.zanxiang.game.module.manage.service.IGameAppletService;
 import com.zanxiang.game.module.manage.service.IGameService;
 import com.zanxiang.module.util.pojo.ResultVO;
 import io.swagger.annotations.Api;
@@ -30,6 +31,9 @@ public class GameController {
     @Autowired
     private IGameService gameService;
 
+    @Autowired
+    private IGameAppletService gameAppletService;
+
     @ApiOperation(value = "新增游戏")
     @PostMapping(value = "/add/or/update")
     @PreAuthorize(permissionKey = "manage:game:add")
@@ -61,4 +65,12 @@ public class GameController {
     public ResultVO<Boolean> statusUpdate(@RequestParam Long id, @RequestParam Integer status) {
         return ResultVO.ok(gameService.statusUpdate(id, status));
     }
+
+    @ApiOperation(value = "创建游戏回传数据源")
+    @PutMapping(value = "/create/game/action/set")
+    @PreAuthorize(permissionKey = "manage:game:createGameActionSet")
+    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = Boolean.class)})
+    public ResultVO<Boolean> createActionSet(@RequestParam Long gameId) {
+        return ResultVO.ok(gameAppletService.createActionSet(gameId));
+    }
 }

+ 2 - 2
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/dto/GameAppletConfigDTO.java

@@ -18,9 +18,9 @@ import lombok.NoArgsConstructor;
 public class GameAppletConfigDTO {
 
     /**
-     * 类型,1 : 小程序, 2 : 公众号
+     * 类型,1 : 小游戏, 2 : 公众号
      */
-    @ApiModelProperty(notes = "类型,1 : 小程序, 2 : 公众号 (必填)")
+    @ApiModelProperty(notes = "类型,1 : 小游戏, 2 : 公众号 (必填)")
     private Integer type;
 
     /**

+ 17 - 97
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/dto/GameDTO.java

@@ -27,120 +27,45 @@ public class GameDTO {
      */
     private String name;
 
-    /**
-     * appkey
-     */
-    private String appKey;
-
-    /**
-     * 游戏标签
-     */
-    private Long tags;
-
     /**
      * 游戏类型
      */
     private Long category;
 
     /**
-     * 游戏分类id, 多个
+     * H5游戏跳转地址
      */
-    private String classify;
+    private String h5GameUrl;
 
     /**
-     * 游戏分类父id, 多个
+     * H5游戏登录logo图片
      */
-    private String classifyParent;
+    private String h5LoginLogo;
 
     /**
-     * 网页游戏图标,200*200
+     * 游戏是否投放
      */
-    private String icon;
+    private Boolean isPut;
 
     /**
-     * CP回调路径
-     */
-    private String cpPaybackUrl;
-
-    /**
-     * 从属游戏
-     */
-    private Long parentId;
-
-    /**
-     * 包名
+     * 游戏标签
      */
-    private String packageName;
+    private String tags;
 
     /**
-     * 上线状态1 接入中, 2 可上线, 3 已下线
+     * 上线状态 1 : 未接入, 2 : 接入中, 3 : 上线, 4 : 下线
      */
     private Integer status;
 
     /**
-     * 1在线游戏 2 单机
-     */
-    private Boolean isOnline;
-
-    /**
-     * 1 不是SDK游戏  2 是SDK游戏
-     */
-    private Boolean isSdk;
-
-    /**
-     * 游戏宣传语
-     */
-    private String publicity;
-
-    /**
-     * 语言
-     */
-    private String language;
-
-    /**
-     * 游戏描述
-     */
-    private String description;
-
-    /**
-     * 游戏宣传图 JSON格式
-     */
-    private String image;
-
-    /**
-     * 苹果应用ID
-     */
-    private String appleId;
-
-    /**
-     * 是否需要实名认证,1:关闭实名认证,2:强制实名认证  3:开启实名认证
-     */
-    private Integer needAuth;
-
-    /**
-     * 扩展 JSON格式
-     */
-    private String extInfo;
-
-    /**
-     * 上线时间
-     */
-    private LocalDateTime onlineTime;
-
-    /**
-     * 1 删除  0 正常
-     */
-    private Integer isDelete;
-
-    /**
-     * 删除时间
+     * 分成比例
      */
-    private LocalDateTime deleteTime;
+    private Double shareScale;
 
     /**
-     * 分成比例
+     * 父游戏id
      */
-    private Double shareScale;
+    private Long parentId;
 
     /**
      * 关联H5游戏id
@@ -153,19 +78,14 @@ public class GameDTO {
     private Long guideGameId;
 
     /**
-     * 游戏地址
+     * 游戏备注
      */
-    private String gameUrl;
+    private String remark;
 
     /**
-     * 游戏版本
-     */
-    private String version;
-
-    /**
-     * 下载次数
+     * 1 删除  0 正常
      */
-    private Long downloadCount;
+    private Integer isDelete;
 
     /**
      * 创建时间

+ 6 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/vo/UserVO.java

@@ -111,6 +111,12 @@ public class UserVO {
     @ApiModelProperty(notes = "注册游戏")
     private String regGame;
 
+    /**
+     * 游戏类型名称
+     */
+    @ApiModelProperty(notes = "游戏类型名称")
+    private String categoryName;
+
     /**
      * 用户状态, 0 : 为正常状态, 1 : 为冻结状态
      */

+ 8 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/IGameAppletService.java

@@ -22,6 +22,14 @@ public interface IGameAppletService extends IService<GameApplet> {
      */
     boolean addOrUpdate(Game game, GameAppletConfigDTO gameAppletConfigDTO);
 
+    /**
+     * 创建数据源
+     *
+     * @param gameId 游戏id
+     * @return {@link Boolean}
+     */
+    Boolean createActionSet(Long gameId);
+
     /**
      * 通过游戏id
      *

+ 43 - 15
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameAppletServiceImpl.java

@@ -12,7 +12,9 @@ import com.zanxiang.game.module.base.pojo.enums.GameCategoryEnum;
 import com.zanxiang.game.module.base.pojo.enums.StatusEnum;
 import com.zanxiang.game.module.manage.pojo.dto.GameAppletConfigDTO;
 import com.zanxiang.game.module.manage.pojo.dto.GameAppletDTO;
+import com.zanxiang.game.module.manage.pojo.dto.GameDTO;
 import com.zanxiang.game.module.manage.service.IGameAppletService;
+import com.zanxiang.game.module.manage.service.IGameService;
 import com.zanxiang.game.module.mybatis.entity.Game;
 import com.zanxiang.game.module.mybatis.entity.GameApplet;
 import com.zanxiang.game.module.mybatis.mapper.GameAppletMapper;
@@ -21,6 +23,7 @@ import com.zanxiang.module.util.JsonUtil;
 import com.zanxiang.module.util.URIUtil;
 import com.zanxiang.module.util.bean.BeanUtil;
 import com.zanxiang.module.util.exception.BaseException;
+import com.zanxiang.module.util.pojo.ResultVO;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.apache.logging.log4j.util.Strings;
@@ -32,10 +35,7 @@ import java.io.PrintWriter;
 import java.net.HttpURLConnection;
 import java.net.URL;
 import java.time.LocalDateTime;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-import java.util.UUID;
+import java.util.*;
 
 /**
  * @author : lingfeng
@@ -52,6 +52,9 @@ public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApp
     @Autowired
     private IOssService ossService;
 
+    @Autowired
+    private IGameService gameService;
+
     @Override
     public boolean addOrUpdate(Game game, GameAppletConfigDTO gameAppletConfigDTO) {
         GameApplet gameApplet = super.getOne(new LambdaQueryWrapper<GameApplet>()
@@ -59,17 +62,7 @@ public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApp
                 .eq(GameApplet::getGameId, game.getId())
         );
         if (gameApplet == null) {
-            CreateUserActionSetRpcDTO actionSetRpcDTO = CreateUserActionSetRpcDTO.builder()
-                    .appId(gameAppletConfigDTO.getAppId())
-                    .build();
-            //小游戏需要创建数据源
-            if (Objects.equals(GameCategoryEnum.CATEGORY_WX_APPLET.getId(), game.getCategory())) {
-//                userActionSetRpc.create(actionSetRpcDTO);
-            }
-            //H5游戏要判断是否主游戏, 主游戏才投, 需要创建公众号数据源
-            if (game.getParentId() == null && Objects.equals(GameCategoryEnum.CATEGORY_H5.getId(), game.getCategory())) {
-//                userActionSetRpc.create(actionSetRpcDTO);
-            }
+            this.createActionSet(game.getCategory(), game.getIsPut(), gameAppletConfigDTO.getAppId(), game.getName());
             gameApplet = GameApplet.builder()
                     .gameId(game.getId())
                     .appId(gameAppletConfigDTO.getAppId())
@@ -105,6 +98,41 @@ public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApp
         return super.saveOrUpdate(gameApplet);
     }
 
+    @Override
+    public Boolean createActionSet(Long gameId) {
+        GameDTO gameDTO = gameService.getById(gameId);
+        GameAppletDTO gameAppletDTO = this.getByGameId(gameId);
+        if (gameDTO == null || gameAppletDTO == null) {
+            log.error("创建数据源失败, 游戏信息数据不全 gameDTO : {}, gameAppletDTO : {}",
+                    JsonUtil.toString(gameDTO), JsonUtil.toString(gameAppletDTO));
+            return Boolean.FALSE;
+        }
+        return this.createActionSet(gameDTO.getCategory(), gameDTO.getIsPut(), gameAppletDTO.getAppId(), gameDTO.getName());
+    }
+
+    private Boolean createActionSet(Long gameCategory, Boolean isPut, String appId, String gameName) {
+        CreateUserActionSetRpcDTO actionSetRpcDTO = CreateUserActionSetRpcDTO.builder()
+                .appId(appId).type("WEB").name(gameName + "Web数据源").build();
+        //小游戏和H5的类型才需要创建数据源
+        List<Long> categoryList = Arrays.asList(GameCategoryEnum.CATEGORY_WX_APPLET.getId(), GameCategoryEnum.CATEGORY_H5.getId());
+        //投放的游戏才需要设置数据源
+        if (!categoryList.contains(gameCategory) || !Objects.equals(isPut, Boolean.TRUE)) {
+            return Boolean.FALSE;
+        }
+        //调用回传服务创建数据源
+        ResultVO<Boolean> booleanResultVO = null;
+        try {
+            log.error("数据源创建提交参数, actionSetRpcDTO : {}", JsonUtil.toString(actionSetRpcDTO));
+            booleanResultVO = userActionSetRpc.create(actionSetRpcDTO);
+        } catch (Exception e) {
+            log.error("调用回传服务创建数据源异常, gameCategory : {}, appId : {}, actionSetRpcDTO : {}, e : {}",
+                    gameCategory, appId, JsonUtil.toString(actionSetRpcDTO), e.getMessage());
+        }
+        log.error("创建数据源结果 actionSetRpcDTO : {}, booleanResultVO : {}",
+                JsonUtil.toString(actionSetRpcDTO), JsonUtil.toString(booleanResultVO));
+        return booleanResultVO == null ? Boolean.FALSE : booleanResultVO.getData();
+    }
+
     @Override
     public GameAppletDTO getByGameId(Long gameId) {
         GameApplet gameApplet = super.getOne(new LambdaQueryWrapper<GameApplet>()

+ 1 - 1
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameUserRoleServiceImpl.java

@@ -107,7 +107,7 @@ public class GameUserRoleServiceImpl extends ServiceImpl<GameUserRoleMapper, Gam
         //渠道id
         List<Long> agentIdList = agentDTOList.stream().map(AgentDTO::getId).collect(Collectors.toList());
         //管理员可见自然量数据
-        if (SecurityUtil.isManager()) {
+        if (SecurityUtil.isManager() && param.getChannelId() == null) {
             agentIdList.add(Agent.DEFAULT_AGENT);
         }
         //玩家条件处理

+ 5 - 2
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameUserServiceImpl.java

@@ -15,10 +15,12 @@ import com.zanxiang.game.module.manage.pojo.params.GameUserListParam;
 import com.zanxiang.game.module.manage.pojo.vo.GameUserListVO;
 import com.zanxiang.game.module.manage.pojo.vo.GameUserVO;
 import com.zanxiang.game.module.manage.service.*;
+import com.zanxiang.game.module.mybatis.entity.Agent;
 import com.zanxiang.game.module.mybatis.entity.GameUser;
 import com.zanxiang.game.module.mybatis.mapper.GameUserMapper;
 import com.zanxiang.module.util.bean.BeanUtil;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.logging.log4j.util.Strings;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -69,8 +71,9 @@ public class GameUserServiceImpl extends ServiceImpl<GameUserMapper, GameUser> i
         //渠道id
         List<Long> agentIdList = agentDTOList.stream().map(AgentDTO::getId).collect(Collectors.toList());
         //管理员可见自然量数据
-        if (SecurityUtil.isManager()) {
-            agentIdList.add(0L);
+        if (SecurityUtil.isManager() && Strings.isBlank(param.getAccountId())
+                && Strings.isBlank(param.getPitcherId()) && param.getChannelId() == null) {
+            agentIdList.add(Agent.DEFAULT_AGENT);
         }
         //玩家条件处理
         Map<Long, UserDTO> userMap = userService.userCondition(param.getUserId(), agentIdList, param.getUserName(),

+ 4 - 2
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/OrderServiceImpl.java

@@ -14,6 +14,7 @@ import com.zanxiang.game.module.manage.pojo.vo.OrderListVO;
 import com.zanxiang.game.module.manage.pojo.vo.OrderVO;
 import com.zanxiang.game.module.manage.pojo.vo.UserOrderListVO;
 import com.zanxiang.game.module.manage.service.*;
+import com.zanxiang.game.module.mybatis.entity.Agent;
 import com.zanxiang.game.module.mybatis.entity.Order;
 import com.zanxiang.game.module.mybatis.entity.User;
 import com.zanxiang.game.module.mybatis.mapper.OrderMapper;
@@ -102,8 +103,9 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         //渠道id列表
         List<Long> agentIds = agentDTOList.stream().map(AgentDTO::getId).collect(Collectors.toList());
         //管理员可见自然量数据
-        if (SecurityUtil.isManager()) {
-            agentIds.add(0L);
+        if (SecurityUtil.isManager() && Strings.isBlank(param.getAccountId())
+                && Strings.isBlank(param.getPitcherId()) && param.getChannelId() == null) {
+            agentIds.add(Agent.DEFAULT_AGENT);
         }
         //查询用户id和名字条件
         List<Long> userIds = null;

+ 2 - 1
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/UserCardServiceImpl.java

@@ -14,6 +14,7 @@ import com.zanxiang.game.module.manage.pojo.vo.UserCardVO;
 import com.zanxiang.game.module.manage.service.IAgentService;
 import com.zanxiang.game.module.manage.service.IUserCardService;
 import com.zanxiang.game.module.manage.service.IUserService;
+import com.zanxiang.game.module.mybatis.entity.Agent;
 import com.zanxiang.game.module.mybatis.entity.UserCard;
 import com.zanxiang.game.module.mybatis.mapper.UserCardMapper;
 import com.zanxiang.module.util.bean.BeanUtil;
@@ -57,7 +58,7 @@ public class UserCardServiceImpl extends ServiceImpl<UserCardMapper, UserCard> i
         List<Long> agentIdList = agentDTOList.stream().map(AgentDTO::getId).collect(Collectors.toList());
         //管理员可见自然量数据
         if (SecurityUtil.isManager()) {
-            agentIdList.add(0L);
+            agentIdList.add(Agent.DEFAULT_AGENT);
         }
         //玩家条件处理
         Map<Long, UserDTO> userMap = userService.userCondition(param.getUserId(), agentIdList, param.getUserName(),

+ 4 - 2
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/UserServiceImpl.java

@@ -78,8 +78,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
         //渠道id列表
         List<Long> agentIdList = agentDTOList.stream().map(AgentDTO::getId).collect(Collectors.toList());
         //管理员可见自然量数据
-        if (SecurityUtil.isManager()) {
-            agentIdList.add(0L);
+        if (SecurityUtil.isManager() && Strings.isBlank(param.getAccountId())
+                && Strings.isBlank(param.getPitcherId()) && param.getChannelId() == null) {
+            agentIdList.add(Agent.DEFAULT_AGENT);
         }
         Map<Long, CpDTO> cpMap = cpService.cpMap();
         Map<Long, AgentDTO> agentMap = agentDTOList.stream().collect(Collectors.toMap(AgentDTO::getId, Function.identity()));
@@ -181,6 +182,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
         GameDTO gameDTO = gameService.getById(user.getGameId());
         if (gameDTO != null) {
             userVO.setRegGame(gameDTO.getName());
+            userVO.setCategoryName(GameCategoryEnum.getNameByCategory(gameDTO.getCategory()));
         }
         //渠道
         Agent agent = agentService.getById(user.getAgentId());

+ 1 - 1
game-module/game-module-mybatis/src/main/java/com/zanxiang/game/module/mybatis/entity/GameApplet.java

@@ -56,7 +56,7 @@ public class GameApplet implements Serializable {
     private String appSecret;
 
     /**
-     * 类型,1 : 小程序, 2 : 公众号
+     * 类型,1 : 小游戏, 2 : 公众号
      */
     private Integer type;
 

+ 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));
     }
 }

+ 10 - 4
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/controller/PayController.java

@@ -17,7 +17,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
-import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
@@ -35,7 +34,7 @@ import java.util.Map;
 @Slf4j
 public class PayController {
 
-    @Resource
+    @Autowired
     private IOrderPayService orderPayService;
 
     @Autowired
@@ -44,8 +43,15 @@ public class PayController {
     @UnSignCheck
     @ApiOperation(value = "获取客服支付参数")
     @GetMapping(value = "/param/applet")
-    public ResultVO<PayParamVO> getPayParam(@RequestParam String code, @RequestParam String orderId, HttpServletRequest request) {
-        return ResultVO.ok(orderPayService.getPayParam(code, orderId, request));
+    public ResultVO<PayParamVO> getCustomPayParam(@RequestParam String code, @RequestParam String orderId, HttpServletRequest request) {
+        return ResultVO.ok(orderPayService.getPayParam(code, null, orderId, request));
+    }
+
+    @ApiOperation(value = "获取公众号支付参数")
+    @GetMapping(value = "/param/mp")
+    public ResultVO<PayParamVO> getMpPayParam(@RequestParam String openId, @RequestParam String orderId,
+                                              @ValidLogin UserData userData, HttpServletRequest request) {
+        return ResultVO.ok(orderPayService.getPayParam(null, openId, orderId, request));
     }
 
     @ApiOperation(value = "获取小游戏支付方式")

+ 5 - 0
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/pojo/dto/ProductPayParamDTO.java

@@ -72,6 +72,11 @@ public class ProductPayParamDTO {
      */
     private String code;
 
+    /**
+     * 公众号支付的openId
+     */
+    private String openId;
+
     /**
      * 支付类型详情(android / ios/ window)
      */

+ 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);
 }

+ 2 - 1
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/IOrderPayService.java

@@ -21,9 +21,10 @@ public interface IOrderPayService {
      * @param code    代码
      * @param orderId 订单id
      * @param request 请求
+     * @param openId  用户公众号唯一标识
      * @return {@link PayParamVO}
      */
-    PayParamVO getPayParam(String code, String orderId, HttpServletRequest request);
+    PayParamVO getPayParam(String code, String openId, String orderId, HttpServletRequest request);
 
     /**
      * 获取小游戏支付方式

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

@@ -2,6 +2,7 @@ package com.zanxiang.game.module.sdk.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.zanxiang.game.module.mybatis.entity.Order;
+import com.zanxiang.game.module.mybatis.entity.User;
 import com.zanxiang.game.module.sdk.pojo.dto.PlatformOrderDTO;
 import com.zanxiang.game.module.sdk.pojo.param.ProductPayParam;
 import com.zanxiang.game.module.sdk.pojo.param.UserData;
@@ -20,9 +21,10 @@ public interface IOrderService extends IService<Order> {
      *
      * @param payParam 支付参数
      * @param userData 用户数据
+     * @param user     用户
      * @return {@link Boolean}
      */
-    Boolean createOrder(ProductPayParam payParam, UserData userData);
+    Boolean createOrder(ProductPayParam payParam, User user, UserData userData);
 
     /**
      * 单一订单详情获取

+ 8 - 2
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/AgentServiceImpl.java

@@ -66,7 +66,10 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
         //30天未登录, 更新渠道
         Map<String, String> urlParamMap = this.channelTransform(channel);
         //查询渠道
-        String state = urlParamMap.get("state");
+        String state = urlParamMap.get("agentKey");
+        if (Strings.isBlank(state)) {
+            state = urlParamMap.get("state");
+        }
         Agent agent = super.getOne(new LambdaQueryWrapper<Agent>()
                 .eq(Agent::getAgentKey, state));
         if (agent == null) {
@@ -94,7 +97,10 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
         //数据解析
         Map<String, String> urlParamMap = this.channelTransform(channel);
         //查询渠道
-        String state = urlParamMap.get("state");
+        String state = urlParamMap.get("agentKey");
+        if (Strings.isBlank(state)) {
+            state = urlParamMap.get("state");
+        }
         Agent agent = super.getOne(new LambdaQueryWrapper<Agent>()
                 .eq(Agent::getAgentKey, state));
         if (agent == null) {

+ 7 - 0
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/CallBackServiceImpl.java

@@ -14,6 +14,7 @@ import com.zanxiang.game.module.base.pojo.enums.GameCategoryEnum;
 import com.zanxiang.game.module.mybatis.entity.*;
 import com.zanxiang.game.module.sdk.pojo.dto.PlatformOrderDTO;
 import com.zanxiang.game.module.sdk.service.*;
+import com.zanxiang.module.util.JsonUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -75,10 +76,12 @@ public class CallBackServiceImpl implements ICallBackService {
         //查询小游戏信息或者H5游戏相关公众号信息
         GameApplet gameApplet = gameAppletService.getOne(new LambdaQueryWrapper<GameApplet>()
                 .eq(GameApplet::getGameId, user.getGameId()));
+        log.error("用户注册回传, userId : {}", user.getId());
         try {
             //腾讯回传
             if (Objects.equals(agent.getAccountType(), Agent.ACCOUNT_TYPE_TENCENT)) {
                 TencentUserDTO tencentUserDTO = this.transform(user, agent, gameApplet);
+                log.error("用户注册 --> 腾讯回传提交, tencentUserDTO : {}", JsonUtil.toString(tencentUserDTO));
                 gameBackTencentRpc.backUser(tencentUserDTO);
             }
             //头条回传
@@ -87,6 +90,7 @@ public class CallBackServiceImpl implements ICallBackService {
                 //判断是微信小游戏
                 if (Objects.equals(game.getCategory(), GameCategoryEnum.CATEGORY_WX_APPLET.getId())) {
                     UserActiveReportRpcDTO activeReportRpcDTO = this.transform(user, agent, gameApplet, urlParamMap);
+                    log.error("用户注册 --> 头条回传提交, activeReportRpcDTO : {}", JsonUtil.toString(activeReportRpcDTO));
                     wechatMiniGameDataReportRpc.userActiveReport(activeReportRpcDTO);
                 }
             }
@@ -112,10 +116,12 @@ public class CallBackServiceImpl implements ICallBackService {
         //查询小游戏信息或者H5游戏相关公众号信息
         GameApplet gameApplet = gameAppletService.getOne(new LambdaQueryWrapper<GameApplet>()
                 .eq(GameApplet::getGameId, user.getGameId()));
+        log.error("用户订单回传, orderId : {}", platformOrderDTO.getOrderId());
         try {
             //腾讯回传
             if (Objects.equals(agent.getAccountType(), Agent.ACCOUNT_TYPE_TENCENT)) {
                 TencentOrderDTO tencentOrderDTO = this.transform(platformOrderDTO, user, agent, gameApplet);
+                log.error("用户下单 --> 腾讯回传提交, tencentOrderDTO : {}", JsonUtil.toString(tencentOrderDTO));
                 gameBackTencentRpc.backOrder(tencentOrderDTO);
             }
             //头条回传
@@ -124,6 +130,7 @@ public class CallBackServiceImpl implements ICallBackService {
                 Game game = gameService.getById(platformOrderDTO.getGameId());
                 if (Objects.equals(game.getCategory(), GameCategoryEnum.CATEGORY_WX_APPLET.getId())) {
                     OrderReportRpcDTO orderReportRpcDTO = this.transform(platformOrderDTO, user.getOpenId(), agent, gameApplet);
+                    log.error("用户下单 --> 头条回传提交, orderReportRpcDTO : {}", JsonUtil.toString(orderReportRpcDTO));
                     wechatMiniGameDataReportRpc.orderReport(orderReportRpcDTO);
                 }
             }

+ 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));
         }

+ 57 - 43
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/OrderPayServiceImpl.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.zanxiang.game.module.base.pojo.enums.PayDeviceEnum;
 import com.zanxiang.game.module.mybatis.entity.Order;
 import com.zanxiang.game.module.mybatis.entity.OrderPayParam;
+import com.zanxiang.game.module.mybatis.entity.User;
 import com.zanxiang.game.module.sdk.enums.DeviceTypeEnum;
 import com.zanxiang.game.module.sdk.enums.OrderStateEnum;
 import com.zanxiang.game.module.sdk.enums.PayTypeEnum;
@@ -17,6 +18,7 @@ import com.zanxiang.game.module.sdk.service.*;
 import com.zanxiang.game.module.sdk.service.pay.PayBaseService;
 import com.zanxiang.game.module.sdk.util.SpringUtils;
 import com.zanxiang.module.util.JsonUtil;
+import com.zanxiang.module.util.bean.BeanUtil;
 import com.zanxiang.module.util.exception.BaseException;
 import com.zanxiang.module.web.util.IpUtil;
 import lombok.extern.slf4j.Slf4j;
@@ -53,6 +55,12 @@ public class OrderPayServiceImpl implements IOrderPayService {
     @Autowired
     private IPayApplicationService payApplicationService;
 
+    @Autowired
+    private IUserService userService;
+
+    @Value("${payConfig.wxPay.customH5Url}")
+    private String customH5Url;
+
     /**
      * 服务器域名
      */
@@ -60,56 +68,59 @@ public class OrderPayServiceImpl implements IOrderPayService {
     private String serverUrl;
 
     @Override
-    public PayParamVO getPayParam(String code, String orderId, HttpServletRequest request) {
-        Order order = orderService.getOne(new LambdaQueryWrapper<Order>()
-                .eq(Order::getOrderId, orderId));
-        log.error("获取订单支付参数, code : {}, orderId : {}", code, orderId);
-        if (order == null) {
-            throw new BaseException("参数错误, 订单信息不存在");
-        }
-        if (Objects.equals(order.getStatus(), OrderStateEnum.CANCEL_PAY.getCode())) {
-            throw new BaseException("订单已关闭, 请回到游戏重新下单");
-        }
-        if (Objects.equals(order.getStatus(), OrderStateEnum.SUCCESS_PAY.getCode())) {
-            throw new BaseException("订单已支付, 请勿重复支付");
-        }
+    public PayParamVO getPayParam(String code, String openId, String orderId, HttpServletRequest request) {
+        log.error("获取订单支付参数, code : {}, openId : {}, orderId : {}", code, openId, orderId);
+        Order order = this.orderFindAndCheck(orderId);
         OrderPayParam orderPayParam = orderPayParamService.getOne(new LambdaQueryWrapper<OrderPayParam>()
                 .eq(OrderPayParam::getOrderId, order.getOrderId()));
         if (orderPayParam != null) {
-            return PayParamVO.builder()
-                    .orderId(orderPayParam.getOrderId())
-                    .appId(orderPayParam.getAppId())
-                    .payParam(orderPayParam.getPayParam())
-                    .build();
+            return BeanUtil.copy(orderPayParam, PayParamVO.class);
         }
         //创建支付参数
-        ProductPayParamDTO bo = ProductPayParamDTO.builder()
-                .gameId(order.getGameId())
-                .userId(order.getUserId())
-                .payDevice(order.getPayDeviceId())
-                .deviceSystem(order.getDeviceSystem())
-                .spbillCreateIp(IpUtil.getRealIp(request))
-                .outTradeNo(order.getOrderId())
-                .payWay(order.getPayWayId())
-                .code(code)
-                .build();
+        ProductPayParamDTO productPayParamDTO = this.transform(order, code, openId, IpUtil.getRealIp(request));
         //调起支付
-        PayTypeEnum payTypeEnum = PayTypeEnum.getByPayType(bo.getPayWay().intValue());
+        PayTypeEnum payTypeEnum = PayTypeEnum.getByPayType(productPayParamDTO.getPayWay().intValue());
         PayBaseService service = SpringUtils.getBean(payTypeEnum.getClazz());
-        service.payCreate(bo);
+        service.payCreate(productPayParamDTO);
         //重新查询
         orderPayParam = orderPayParamService.getOne(new LambdaQueryWrapper<OrderPayParam>()
                 .eq(OrderPayParam::getOrderId, order.getOrderId()));
         if (orderPayParam == null) {
+            log.error("支付参数获取失败, orderId : {}", orderId);
             throw new BaseException("支付参数获取失败");
         }
-        return PayParamVO.builder()
-                .orderId(orderPayParam.getOrderId())
-                .appId(orderPayParam.getAppId())
-                .payParam(orderPayParam.getPayParam())
+        //返回支付参数
+        return BeanUtil.copy(orderPayParam, PayParamVO.class);
+    }
+
+    private ProductPayParamDTO transform(Order order, String code, String openId, String ip) {
+        return ProductPayParamDTO.builder()
+                .gameId(order.getGameId())
+                .userId(order.getUserId())
+                .payDevice(order.getPayDeviceId())
+                .deviceSystem(order.getDeviceSystem())
+                .spbillCreateIp(ip)
+                .outTradeNo(order.getOrderId())
+                .payWay(order.getPayWayId())
+                .code(code)
+                .openId(openId)
                 .build();
     }
 
+    private Order orderFindAndCheck(String orderId) {
+        Order order = orderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderId, orderId));
+        if (order == null) {
+            throw new BaseException("参数错误, 订单信息不存在");
+        }
+        if (Objects.equals(order.getStatus(), OrderStateEnum.CANCEL_PAY.getCode())) {
+            throw new BaseException("订单已关闭, 请回到游戏重新下单");
+        }
+        if (Objects.equals(order.getStatus(), OrderStateEnum.SUCCESS_PAY.getCode())) {
+            throw new BaseException("订单已支付, 请勿重复支付");
+        }
+        return order;
+    }
+
     @Override
     public Long getAppletPayDevice(UserData userData) {
         log.error("获取支付类型参数, 请求信息 userData : {}", JsonUtil.toString(userData));
@@ -147,26 +158,29 @@ public class OrderPayServiceImpl implements IOrderPayService {
 
     @Override
     public Map<String, Object> payCreate(ProductPayParam product, UserData userData) {
+        //用户信息
+        User user = userService.getById(userData.getUserId());
+        if (user == null) {
+            throw new BaseException("参数错误, 用户信息不存在");
+        }
         //创建订单
-        orderService.createOrder(product, userData);
+        orderService.createOrder(product, user, userData);
         //判断游戏类型
-        if (Objects.equals(PayDeviceEnum.APPLET_PAY.getPayDeviceId(), product.getPayDevice())
-                || Objects.equals(PayDeviceEnum.CUSTOM_PAY.getPayDeviceId(), product.getPayDevice())) {
+        if (PayDeviceEnum.getByPayWayIdList().contains(product.getPayDevice())) {
             //查询支付配置
             GamePayWayDTO gamePayWayDTO = gamePayWayService.getGamePayWay(userData.getGameId(), product.getPayWay(), product.getPayDevice());
             //查询支付应用信息
             PayApplicationDTO payApplicationDTO = payApplicationService.getPayApplicationByPayBoxId(gamePayWayDTO.getPayBoxId());
             //构造参数信息
-            Map<String, Object> paramMap = new HashMap<>(4);
+            Map<String, Object> paramMap = new HashMap<>(8);
             paramMap.put("appId", payApplicationDTO.getAppId());
             paramMap.put("path", payApplicationDTO.getPath());
             paramMap.put("orderId", product.getOrderId());
             paramMap.put("amount", product.getAmount());
-            if (this.serverUrl.contains("84game")) {
-                paramMap.put("serverUrl", this.serverUrl + "/sdk");
-            } else {
-                paramMap.put("serverUrl", this.serverUrl + "/api/sdk");
-            }
+            paramMap.put("payH5Url", this.customH5Url);
+            paramMap.put("openId", user.getOpenId());
+            paramMap.put("description", "购买" + product.getAmount() + "元档充值");
+            paramMap.put("serverUrl", this.serverUrl.contains("84game") ? this.serverUrl + "/sdk" : this.serverUrl + "/api/sdk");
             log.error("下单参数返回, paramMap : {}", JsonUtil.toString(paramMap));
             return paramMap;
         }

+ 8 - 21
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/OrderServiceImpl.java

@@ -9,6 +9,7 @@ import com.zanxiang.game.module.sdk.pojo.dto.PlatformOrderDTO;
 import com.zanxiang.game.module.sdk.pojo.param.ProductPayParam;
 import com.zanxiang.game.module.sdk.pojo.param.UserData;
 import com.zanxiang.game.module.sdk.service.*;
+import com.zanxiang.module.util.JsonUtil;
 import com.zanxiang.module.util.bean.BeanUtil;
 import com.zanxiang.module.util.exception.BaseException;
 import lombok.extern.slf4j.Slf4j;
@@ -33,9 +34,6 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
     @Autowired
     private IGameService gameService;
 
-    @Autowired
-    private IUserService userService;
-
     @Autowired
     private IGameUserService gameUserService;
 
@@ -50,34 +48,23 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 
     @Override
     @Transactional(rollbackFor = {Exception.class, RuntimeException.class})
-    public Boolean createOrder(ProductPayParam payParam, UserData userData) {
-        //用户id
-        Long userId = userData.getUserId();
+    public Boolean createOrder(ProductPayParam payParam, User user, UserData userData) {
         //游戏id
         Long gameId = userData.getGameId();
         //游戏信息
-        Game game = gameService.getById(userData.getGameId());
-        if (game == null) {
-            throw new BaseException("参数错误, 游戏信息不存在");
-        }
-        //用户信息
-        User user = userService.getById(userId);
-        if (user == null) {
-            throw new BaseException("参数错误, 用户信息不存在");
-        }
+        Game game = gameService.getById(gameId);
         //玩家信息
         GameUser gameUser = gameUserService.getOne(new LambdaQueryWrapper<GameUser>()
                 .eq(GameUser::getUserId, userData.getUserId()));
-        if (gameUser == null) {
-            throw new BaseException("参数错误, 玩家信息不存在");
-        }
         //角色信息
         GameUserRole gameUserRole = gameUserRoleService.getOne(new LambdaQueryWrapper<GameUserRole>()
-                .eq(GameUserRole::getGameId, userData.getGameId())
+                .eq(GameUserRole::getGameId, gameId)
                 .eq(GameUserRole::getUserId, userData.getUserId())
                 .eq(GameUserRole::getRoleId, payParam.getRoleId()));
-        if (gameUserRole == null) {
-            throw new BaseException("参数错误, 角色信息不存在");
+        if (game == null || gameUser == null || gameUserRole == null) {
+            log.error("游戏用户信息不全, game : {}, gameUser : {}, gameUserRole : {}", JsonUtil.toString(game),
+                    JsonUtil.toString(gameUser), JsonUtil.toString(gameUserRole));
+            throw new BaseException("参数错误, 游戏用户信息不全");
         }
         //游戏支付配置信息
         GamePayWayDTO gamePayWayDTO = gamePayWayService.getGamePayWay(gameId, payParam.getPayWay(), payParam.getPayDevice());

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

@@ -98,10 +98,19 @@ public class UserTokenServiceImpl extends ServiceImpl<UserTokenMapper, UserToken
 
     @Override
     public Boolean userTokenExpireTimeCheck(UserData userData) {
+        log.error("缓存token验证请求 userData : {}", JsonUtil.toString(userData));
         //判断是否存在用户id或者token是否存在
         if (userData.getUserId() == null || Strings.isBlank(userData.getToken())) {
             return Boolean.FALSE;
         }
+        //判断token在数据库是否存在
+        UserToken userToken = super.getOne(new LambdaQueryWrapper<UserToken>()
+                .eq(UserToken::getToken, userData.getToken())
+                .eq(UserToken::getDeviceType, userData.getDeviceType()));
+        //token已经更新, 返回失效
+        if (userToken == null) {
+            return Boolean.FALSE;
+        }
         //判断是否ip封禁
         if (ipBanService.checkIpBan(userData.getIp())) {
             return Boolean.FALSE;

+ 1 - 2
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/pay/AliPayService.java

@@ -126,13 +126,13 @@ public class AliPayService extends PayBaseService {
         orderService.update(new LambdaUpdateWrapper<Order>()
                 .set(Order::getMerchantNo, payMerchant.getMerchantNo())
                 .eq(Order::getOrderId, product.getOutTradeNo()));
+        log.error("返回支付参数 resultMap : {}", JsonUtil.toString(resultMap));
         //返回结果
         return resultMap;
     }
 
     @Override
     public String notify(HttpServletRequest request, HttpServletResponse response) {
-        log.error("支付宝异步回调 -------start----->");
         //解密回调参数
         Map<String, String> params = new HashMap<>(26);
         Enumeration<String> parameterNames = request.getParameterNames();
@@ -173,7 +173,6 @@ public class AliPayService extends PayBaseService {
                     .eq(Order::getOrderId, orderNo));
         }
         //返回消息接收成功
-        log.error("支付宝异步回调 -------end----->");
         return HttpStatusEnum.SUCCESS.getMsg();
     }
 

+ 1 - 1
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/pay/PayBaseService.java

@@ -85,7 +85,7 @@ public abstract class PayBaseService {
             this.attach = attachBO;
             return this.create(product, gamePayWayDTO);
         } catch (Exception e) {
-            log.info("订单支付参数生成异常, ProductPayParamBO : {} , e: {}", JsonUtil.toString(product), e);
+            log.error("订单支付参数生成异常, ProductPayParamBO : {} , e: {}", JsonUtil.toString(product), e.getMessage());
             throw new BaseException("订单支付参数生成异常");
         }
     }

+ 14 - 16
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/pay/WxPayService.java

@@ -118,6 +118,7 @@ public class WxPayService extends PayBaseService {
                 break;
             case 4:
             case 6:
+            case 7:
                 //小程序
                 resultMap = this.miniAppPay(product);
                 break;
@@ -132,6 +133,7 @@ public class WxPayService extends PayBaseService {
                 .set(Order::getStatus, OrderStateEnum.WAIT_PAY.getCode())
                 .eq(Order::getOrderId, product.getOutTradeNo()));
         //返回支付参数
+        log.error("返回支付参数 resultMap : {}", JsonUtil.toString(resultMap));
         return resultMap;
     }
 
@@ -142,10 +144,7 @@ public class WxPayService extends PayBaseService {
         String requestStr = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
         // 解析xml成map
         Map<String, String> packageParams = XmlUtil.xmlToMap(requestStr);
-
-        log.error("微信支付回调参数, packageParams : {}", JsonUtil.toString(packageParams));
-
-
+        log.error("微信支付回调参数, packageParams : {}, config : {}", JsonUtil.toString(packageParams), JsonUtil.toString(config));
         //获取订单信息
         String attachStr = packageParams.get("attach");
         ProductPayAttachParamDTO attachBO = JsonUtil.toObj(attachStr, ProductPayAttachParamDTO.class);
@@ -157,11 +156,6 @@ public class WxPayService extends PayBaseService {
             return null;
         }
         configInit(gamePayWayService.getById(attachBO.getGamePayWayId()));
-
-
-        log.error("微信支付回调参数, config : {}", JsonUtil.toString(config));
-
-
         // 账号信息
         String key = config.getApiKey();
         // 判断签名是否正确
@@ -239,9 +233,13 @@ public class WxPayService extends PayBaseService {
 
     private Map<String, Object> miniAppPay(ProductPayParamDTO product) {
         try {
-            //获取用户openId
-            String openId = wxApiService.getOpenIdByType(product.getCode(), config.getAppId(), config.getAppSecret(),
-                    config.getAppletType()).get("openid");
+            //用户openId
+            String openId = product.getOpenId();
+            //传了code, 自己获取openId
+            if (Strings.isBlank(openId) && Strings.isNotBlank(product.getCode())) {
+                openId = wxApiService.getOpenIdByType(product.getCode(), config.getAppId(), config.getAppSecret(),
+                        config.getAppletType()).get("openid");
+            }
             //下单
             Map<String, String> successMap = this.unifiedOrder(product, WX_PAY_JSAPI, openId);
             // 支付参数
@@ -260,7 +258,8 @@ public class WxPayService extends PayBaseService {
             // 再次签名sign,这个签名用于小程序端调用支付方法
             String sign = WxPayUtil.generateSignature(map, config.getApiKey());
             //组装支付参数
-            Map<String, Object> payParamMap = new HashMap<>(5);
+            Map<String, Object> payParamMap = new HashMap<>(6);
+            payParamMap.put("appId", config.getAppId());
             payParamMap.put("paySign", sign);
             payParamMap.put("signType", config.getSignType());
             payParamMap.put("timeStamp", createTime);
@@ -363,9 +362,8 @@ public class WxPayService extends PayBaseService {
         PayMerchantDTO payMerchantDTO;
         //支付应用信息
         PayApplicationDTO payApplicationDTO;
-        //小程序支付和客服支付, 关联了盒子
-        if (Objects.equals(PayDeviceEnum.APPLET_PAY.getPayDeviceId(), gamePayWayDTO.getPayDeviceId())
-                || Objects.equals(PayDeviceEnum.CUSTOM_PAY.getPayDeviceId(), gamePayWayDTO.getPayDeviceId())) {
+        //小程序支付, 客服支付, 公众号支付, 关联了盒子
+        if (PayDeviceEnum.getByPayWayIdList().contains(gamePayWayDTO.getPayDeviceId())) {
             payMerchantDTO = payBoxService.getMerchantByBoxId(gamePayWayDTO.getPayBoxId());
             payApplicationDTO = payApplicationService.getPayApplicationByPayBoxId(gamePayWayDTO.getPayBoxId());
         } else {

+ 3 - 3
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/util/RegisterUtil.java

@@ -19,12 +19,12 @@ public class RegisterUtil {
     /**
      * 用户名最小长度
      */
-    private static final int USER_NAME_LENGTH_MIN = 4;
+    private static final int USER_NAME_LENGTH_MIN = 8;
 
     /**
      * 用户名最大长度
      */
-    private static final int USER_NAME_LENGTH_MAX = 32;
+    private static final int USER_NAME_LENGTH_MAX = 16;
 
     /**
      * 密码最小长度
@@ -34,7 +34,7 @@ public class RegisterUtil {
     /**
      * 密码最大长度
      */
-    private static final int PASSWORD_LENGTH_MAX = 32;
+    private static final int PASSWORD_LENGTH_MAX = 24;
 
     /**
      * 用户名合规检测