|  | @@ -1,17 +1,23 @@
 | 
	
		
			
				|  |  |  package com.zanxiang.game.module.sdk.service.impl;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 | 
	
		
			
				|  |  | +import com.zanxiang.game.module.base.pojo.enums.AccountTypeEnum;
 | 
	
		
			
				|  |  | +import com.zanxiang.game.module.base.pojo.enums.GameCategoryEnum;
 | 
	
		
			
				|  |  | +import com.zanxiang.game.module.mybatis.entity.Agent;
 | 
	
		
			
				|  |  |  import com.zanxiang.game.module.mybatis.entity.Game;
 | 
	
		
			
				|  |  |  import com.zanxiang.game.module.mybatis.mapper.GameMapper;
 | 
	
		
			
				|  |  |  import com.zanxiang.game.module.sdk.pojo.param.UserData;
 | 
	
		
			
				|  |  | +import com.zanxiang.game.module.sdk.service.IAgentService;
 | 
	
		
			
				|  |  |  import com.zanxiang.game.module.sdk.service.IGameService;
 | 
	
		
			
				|  |  |  import com.zanxiang.module.util.JsonUtil;
 | 
	
		
			
				|  |  |  import lombok.extern.slf4j.Slf4j;
 | 
	
		
			
				|  |  |  import org.apache.logging.log4j.util.Strings;
 | 
	
		
			
				|  |  | +import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import java.util.Collections;
 | 
	
		
			
				|  |  |  import java.util.Map;
 | 
	
		
			
				|  |  | +import java.util.Objects;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  |   * @author : lingfeng
 | 
	
	
		
			
				|  | @@ -22,12 +28,33 @@ import java.util.Map;
 | 
	
		
			
				|  |  |  @Service
 | 
	
		
			
				|  |  |  public class GameServiceImpl extends ServiceImpl<GameMapper, Game> implements IGameService {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private IAgentService agentService;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public Map<String, Object> getAdSdkConfig(UserData userData) {
 | 
	
		
			
				|  |  |          Game game = super.getById(userData.getGameId());
 | 
	
		
			
				|  |  |          if (Strings.isBlank(game.getAdSdkConfig())) {
 | 
	
		
			
				|  |  |              return Collections.singletonMap("adSdk", 0);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        return JsonUtil.toMap(game.getAdSdkConfig(), Map.class, Object.class);
 | 
	
		
			
				|  |  | +        //判断是否为APP, APP直接返回配置
 | 
	
		
			
				|  |  | +        if (Objects.equals(game.getCategory(), GameCategoryEnum.CATEGORY_APP.getId())) {
 | 
	
		
			
				|  |  | +            return JsonUtil.toMap(game.getAdSdkConfig(), Map.class, Object.class);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        //微信小游戏, 根据channel, 判断当前是投的腾讯还是头条
 | 
	
		
			
				|  |  | +        if (Objects.equals(game.getCategory(), GameCategoryEnum.CATEGORY_WX_APPLET.getId())) {
 | 
	
		
			
				|  |  | +            //当前调试阶段
 | 
	
		
			
				|  |  | +            if (Objects.equals(game.getStatus(), 2)) {
 | 
	
		
			
				|  |  | +                return JsonUtil.toMap(game.getAdSdkConfig(), Map.class, Object.class);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            //非调试阶段, 目前只有投腾讯才返回
 | 
	
		
			
				|  |  | +            Map<String, String> urlParamMap = agentService.channelTransform(userData.getChannel());
 | 
	
		
			
				|  |  | +            Agent agent = agentService.getAgentByKey(urlParamMap);
 | 
	
		
			
				|  |  | +            if (agent != null && Objects.equals(agent.getAccountType(), AccountTypeEnum.TENCENT_MINI_GAME.getValue())) {
 | 
	
		
			
				|  |  | +                return JsonUtil.toMap(game.getAdSdkConfig(), Map.class, Object.class);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        //默认返回不初始化
 | 
	
		
			
				|  |  | +        return Collections.singletonMap("adSdk", 0);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 |