|
@@ -46,24 +46,39 @@ public class GameServiceImpl extends ServiceImpl<GameMapper, Game> implements IG
|
|
|
if (Objects.equals(game.getCategory(), GameCategoryEnum.CATEGORY_APP.getId())) {
|
|
|
return JsonUtil.toMap(game.getAdSdkConfig(), Map.class, Object.class);
|
|
|
}
|
|
|
- //微信小游戏, 根据归属渠道, 判断当前是投的腾讯还是头条
|
|
|
- if (Objects.equals(game.getCategory(), GameCategoryEnum.CATEGORY_WX_APPLET.getId())) {
|
|
|
- //当前调试阶段
|
|
|
- if (Objects.equals(game.getStatus(), 2)) {
|
|
|
+ //不是微信小程序, 不返回配置
|
|
|
+ if (!Objects.equals(game.getCategory(), GameCategoryEnum.CATEGORY_WX_APPLET.getId())) {
|
|
|
+ //默认返回不初始化
|
|
|
+ return Collections.singletonMap("adSdk", 0);
|
|
|
+ }
|
|
|
+ //目前只有投腾讯才返回
|
|
|
+ Agent agent = this.getUserAgent(userData.getUserId());
|
|
|
+ if (agent != null) {
|
|
|
+ //腾讯广告
|
|
|
+ if (Objects.equals(agent.getAccountType(), AccountTypeEnum.TENCENT_MINI_GAME.getValue())) {
|
|
|
return JsonUtil.toMap(game.getAdSdkConfig(), Map.class, Object.class);
|
|
|
}
|
|
|
- //不存在userId, 无法判断在投的是腾讯还是头条, 不返回配置
|
|
|
- if (userData.getUserId() == null) {
|
|
|
+ //头条广告
|
|
|
+ if (Objects.equals(agent.getAccountType(), AccountTypeEnum.BYTE.getValue())) {
|
|
|
return Collections.singletonMap("adSdk", 0);
|
|
|
}
|
|
|
- //非调试阶段, 目前只有投腾讯才返回,
|
|
|
- User user = userService.getById(userData.getUserId());
|
|
|
- Agent agent = agentService.getById(user.getAgentId());
|
|
|
- if (agent != null && Objects.equals(agent.getAccountType(), AccountTypeEnum.TENCENT_MINI_GAME.getValue())) {
|
|
|
- return JsonUtil.toMap(game.getAdSdkConfig(), Map.class, Object.class);
|
|
|
- }
|
|
|
+ }
|
|
|
+ //当前调试阶段
|
|
|
+ if (userData.getUserId() != null && Objects.equals(game.getStatus(), 2)) {
|
|
|
+ return JsonUtil.toMap(game.getAdSdkConfig(), Map.class, Object.class);
|
|
|
}
|
|
|
//默认返回不初始化
|
|
|
return Collections.singletonMap("adSdk", 0);
|
|
|
}
|
|
|
+
|
|
|
+ private Agent getUserAgent(Long userId) {
|
|
|
+ if (userId == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ User user = userService.getById(userId);
|
|
|
+ if (user == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return agentService.getById(user.getAgentId());
|
|
|
+ }
|
|
|
}
|