Prechádzať zdrojové kódy

fix : sdk游戏后台管理

bilingfeng 1 rok pred
rodič
commit
763b7312eb

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

@@ -17,6 +17,12 @@ import lombok.NoArgsConstructor;
 @Builder
 public class GameAppletConfigDTO {
 
+    /**
+     * 类型,1 : 小程序, 2 : 公众号
+     */
+    @ApiModelProperty(notes = "类型,1 : 小程序, 2 : 公众号 (必填)")
+    private Integer type;
+
     /**
      * 小游戏/公众号应用id
      */
@@ -41,6 +47,24 @@ public class GameAppletConfigDTO {
     @ApiModelProperty(notes = "小游戏/公众号应用密钥 (必填)")
     private String appSecret;
 
+    /**
+     * 小游戏分享标题
+     */
+    @ApiModelProperty(notes = "小游戏分享标题, 游戏类型为小游戏时必填, 游戏为H5时不填")
+    private String shareTitle;
+
+    /**
+     * 小游戏分享路径
+     */
+    @ApiModelProperty(notes = "小游戏分享路径, 游戏类型为小游戏时必填, 游戏为H5时不填")
+    private String sharePath;
+
+    /**
+     * 小游戏分享图片
+     */
+    @ApiModelProperty(notes = "小游戏分享图片, 游戏类型为小游戏时必填, 游戏为H5时不填")
+    private String shareImg;
+
     /**
      * 公司主体信息
      */

+ 11 - 2
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/IGameAppletService.java

@@ -1,9 +1,9 @@
 package com.zanxiang.game.module.manage.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+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.params.GameAccountUpdateParam;
-import com.zanxiang.game.module.manage.pojo.vo.GameAccountVO;
+import com.zanxiang.game.module.mybatis.entity.Game;
 import com.zanxiang.game.module.mybatis.entity.GameApplet;
 
 /**
@@ -13,6 +13,15 @@ import com.zanxiang.game.module.mybatis.entity.GameApplet;
  */
 public interface IGameAppletService extends IService<GameApplet> {
 
+    /**
+     * 添加或更新
+     *
+     * @param game                游戏
+     * @param gameAppletConfigDTO 游戏小程序配置dto
+     * @return boolean
+     */
+    boolean addOrUpdate(Game game, GameAppletConfigDTO gameAppletConfigDTO);
+
     /**
      * 通过游戏id
      *

+ 65 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameAppletServiceImpl.java

@@ -4,8 +4,16 @@ import cn.hutool.http.HttpUtil;
 import cn.hutool.json.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.zanxiang.advertising.tencent.base.AdvertisingTencentServer;
+import com.zanxiang.advertising.tencent.base.pojo.dto.CreateUserActionSetRpcDTO;
+import com.zanxiang.advertising.tencent.base.rpc.IUserActionSetRpc;
+import com.zanxiang.game.module.base.pojo.enums.DeleteEnum;
+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.service.IGameAppletService;
+import com.zanxiang.game.module.mybatis.entity.Game;
 import com.zanxiang.game.module.mybatis.entity.GameApplet;
 import com.zanxiang.game.module.mybatis.mapper.GameAppletMapper;
 import com.zanxiang.module.oss.service.IOssService;
@@ -14,6 +22,7 @@ import com.zanxiang.module.util.URIUtil;
 import com.zanxiang.module.util.bean.BeanUtil;
 import com.zanxiang.module.util.exception.BaseException;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.dubbo.config.annotation.DubboReference;
 import org.apache.logging.log4j.util.Strings;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -22,8 +31,10 @@ import java.io.BufferedInputStream;
 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;
 
 /**
@@ -35,9 +46,63 @@ import java.util.UUID;
 @Service
 public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApplet> implements IGameAppletService {
 
+    @DubboReference(providedBy = AdvertisingTencentServer.SERVER_DUBBO_NAME)
+    private IUserActionSetRpc userActionSetRpc;
+
     @Autowired
     private IOssService ossService;
 
+    @Override
+    public boolean addOrUpdate(Game game, GameAppletConfigDTO gameAppletConfigDTO) {
+        GameApplet gameApplet = super.getOne(new LambdaQueryWrapper<GameApplet>()
+                .eq(GameApplet::getAppId, gameAppletConfigDTO.getAppId()));
+        if (gameApplet == null) {
+            CreateUserActionSetRpcDTO actionSetRpcDTO = CreateUserActionSetRpcDTO.builder()
+                    .appId(gameAppletConfigDTO.getAppId())
+                    .build();
+            //小游戏需要创建数据源
+            if (Objects.equals(GameCategoryEnum.CATEGORY_WX_APPLET.getCategory(), game.getCategory())) {
+                userActionSetRpc.create(actionSetRpcDTO);
+            }
+            //H5游戏要判断是否主游戏, 主游戏才投, 需要创建公众号数据源
+            if (game.getParentId() == null && Objects.equals(GameCategoryEnum.CATEGORY_H5.getCategory(), game.getCategory())) {
+                userActionSetRpc.create(actionSetRpcDTO);
+            }
+            gameApplet = GameApplet.builder()
+                    .gameId(game.getId())
+                    .appId(gameAppletConfigDTO.getAppId())
+                    .ghId(gameAppletConfigDTO.getGhId())
+                    .appName(gameAppletConfigDTO.getAppName())
+                    .appSecret(gameAppletConfigDTO.getAppSecret())
+                    .type(gameAppletConfigDTO.getType())
+                    .shareTitle(gameAppletConfigDTO.getShareTitle())
+                    .sharePath(gameAppletConfigDTO.getSharePath())
+                    .shareImg(gameAppletConfigDTO.getShareImg())
+                    .company(gameAppletConfigDTO.getCompany())
+                    .account(gameAppletConfigDTO.getAccount())
+                    .manager(gameAppletConfigDTO.getManager())
+                    .isDelete(DeleteEnum.NO.getCode())
+                    .status(StatusEnum.YES.getCode())
+                    .createTime(LocalDateTime.now())
+                    .updateTime(LocalDateTime.now())
+                    .build();
+        } else {
+            gameApplet.setAppId(gameAppletConfigDTO.getAppId());
+            gameApplet.setGhId(gameAppletConfigDTO.getGhId());
+            gameApplet.setAppName(gameAppletConfigDTO.getAppName());
+            gameApplet.setAppSecret(gameAppletConfigDTO.getAppSecret());
+            gameApplet.setType(gameAppletConfigDTO.getType());
+            gameApplet.setShareTitle(gameAppletConfigDTO.getShareTitle());
+            gameApplet.setSharePath(gameAppletConfigDTO.getSharePath());
+            gameApplet.setShareImg(gameAppletConfigDTO.getShareImg());
+            gameApplet.setCompany(gameAppletConfigDTO.getCompany());
+            gameApplet.setAccount(gameAppletConfigDTO.getAccount());
+            gameApplet.setManager(gameAppletConfigDTO.getManager());
+            gameApplet.setUpdateTime(LocalDateTime.now());
+        }
+       return super.saveOrUpdate(gameApplet);
+    }
+
     @Override
     public GameAppletDTO getByGameId(Long gameId) {
         GameApplet gameApplet = super.getOne(new LambdaQueryWrapper<GameApplet>()

+ 6 - 5
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameServiceImpl.java

@@ -13,10 +13,7 @@ import com.zanxiang.game.module.manage.pojo.params.GameListParam;
 import com.zanxiang.game.module.manage.pojo.vo.GameChoiceVO;
 import com.zanxiang.game.module.manage.pojo.vo.GameInfoVO;
 import com.zanxiang.game.module.manage.pojo.vo.GameListVO;
-import com.zanxiang.game.module.manage.service.ICpService;
-import com.zanxiang.game.module.manage.service.IGamePayWayService;
-import com.zanxiang.game.module.manage.service.IGameService;
-import com.zanxiang.game.module.manage.service.IGameTagService;
+import com.zanxiang.game.module.manage.service.*;
 import com.zanxiang.game.module.mybatis.entity.Cp;
 import com.zanxiang.game.module.mybatis.entity.Game;
 import com.zanxiang.game.module.mybatis.entity.GameTag;
@@ -53,6 +50,9 @@ public class GameServiceImpl extends ServiceImpl<GameMapper, Game> implements IG
     @Autowired
     private ICpService cpService;
 
+    @Autowired
+    private IGameAppletService gameAppletService;
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Boolean gameAddOrUpdate(GameAddParam param) {
@@ -89,7 +89,8 @@ public class GameServiceImpl extends ServiceImpl<GameMapper, Game> implements IG
         if (!Objects.equals(param.getIsParentGame(), Boolean.TRUE) && param.getParentGameId() != null) {
             game.setParentId(param.getParentGameId());
         }
-        return super.saveOrUpdate(game);
+        super.saveOrUpdate(game);
+        return gameAppletService.addOrUpdate(game, param.getGameAppletConfigDTO());
     }
 
     private String getGameTags(List<Long> tagIdList) {

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

@@ -70,6 +70,21 @@ public class GameApplet implements Serializable {
      */
     private String msgConfig;
 
+    /**
+     * 分享标题
+     */
+    private String shareTitle;
+
+    /**
+     * 分享路径
+     */
+    private String sharePath;
+
+    /**
+     * 分享图片
+     */
+    private String shareImg;
+
     /**
      * 公司主体信息
      */