|
@@ -4,8 +4,16 @@ import cn.hutool.http.HttpUtil;
|
|
import cn.hutool.json.JSONObject;
|
|
import cn.hutool.json.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
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.pojo.dto.GameAppletDTO;
|
|
import com.zanxiang.game.module.manage.service.IGameAppletService;
|
|
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.entity.GameApplet;
|
|
import com.zanxiang.game.module.mybatis.mapper.GameAppletMapper;
|
|
import com.zanxiang.game.module.mybatis.mapper.GameAppletMapper;
|
|
import com.zanxiang.module.oss.service.IOssService;
|
|
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.bean.BeanUtil;
|
|
import com.zanxiang.module.util.exception.BaseException;
|
|
import com.zanxiang.module.util.exception.BaseException;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
import org.apache.logging.log4j.util.Strings;
|
|
import org.apache.logging.log4j.util.Strings;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -22,8 +31,10 @@ import java.io.BufferedInputStream;
|
|
import java.io.PrintWriter;
|
|
import java.io.PrintWriter;
|
|
import java.net.HttpURLConnection;
|
|
import java.net.HttpURLConnection;
|
|
import java.net.URL;
|
|
import java.net.URL;
|
|
|
|
+import java.time.LocalDateTime;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
+import java.util.Objects;
|
|
import java.util.UUID;
|
|
import java.util.UUID;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -35,9 +46,63 @@ import java.util.UUID;
|
|
@Service
|
|
@Service
|
|
public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApplet> implements IGameAppletService {
|
|
public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApplet> implements IGameAppletService {
|
|
|
|
|
|
|
|
+ @DubboReference(providedBy = AdvertisingTencentServer.SERVER_DUBBO_NAME)
|
|
|
|
+ private IUserActionSetRpc userActionSetRpc;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private IOssService ossService;
|
|
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
|
|
@Override
|
|
public GameAppletDTO getByGameId(Long gameId) {
|
|
public GameAppletDTO getByGameId(Long gameId) {
|
|
GameApplet gameApplet = super.getOne(new LambdaQueryWrapper<GameApplet>()
|
|
GameApplet gameApplet = super.getOne(new LambdaQueryWrapper<GameApplet>()
|