|
@@ -11,6 +11,7 @@ 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.*;
|
|
|
import com.zanxiang.game.module.sdk.pojo.dto.PlatformOrderDTO;
|
|
|
+import com.zanxiang.game.module.sdk.pojo.param.UserData;
|
|
|
import com.zanxiang.game.module.sdk.service.*;
|
|
|
import com.zanxiang.module.util.JsonUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -110,6 +111,52 @@ public class CallBackServiceImpl implements ICallBackService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void roleCallBack(GameUserRole gameUserRole, UserData userData) {
|
|
|
+ //判断游戏是否开启广告回传, 未开启, 不回传
|
|
|
+ GameExt gameExt = gameExtService.getByGameId(userData.getGameId());
|
|
|
+ if (!Objects.equals(gameExt.getAdCallBackSwitch(), Boolean.TRUE)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //用户信息
|
|
|
+ User user = userService.getById(userData.getUserId());
|
|
|
+ //用户渠道信息
|
|
|
+ Agent agent = agentService.getAgentByChannel(user.getChannel());
|
|
|
+ if (agent == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //查询小游戏信息或者H5游戏相关公众号信息
|
|
|
+ GameApplet gameApplet = gameAppletService.getOne(new LambdaQueryWrapper<GameApplet>()
|
|
|
+ .eq(GameApplet::getGameId, user.getGameId()));
|
|
|
+ log.error("用户创角回传, userId : {}", user.getId());
|
|
|
+ try {
|
|
|
+ //腾讯H5回传
|
|
|
+ if (Objects.equals(agent.getAccountType(), AccountTypeEnum.TENCENT_H5.getValue())) {
|
|
|
+ TencentRoleRegisterRpcDTO tencentRoleRegisterRpcDTO = this.transform(user, agent, gameApplet, gameUserRole);
|
|
|
+ tencentUserActionBackRpc.backRoleRegister(tencentRoleRegisterRpcDTO);
|
|
|
+ gameBackLogService.addLog(user.getId(), gameUserRole.getRoleId(), "腾讯H5创角回传提交", JsonUtil.toString(tencentRoleRegisterRpcDTO));
|
|
|
+ }
|
|
|
+ //腾讯小游戏回传
|
|
|
+ if (Objects.equals(agent.getAccountType(), AccountTypeEnum.TENCENT_MINI_GAME.getValue())) {
|
|
|
+ TencentRoleRegisterRpcDTO tencentRoleRegisterRpcDTO = this.transform(user, agent, gameApplet, gameUserRole);
|
|
|
+ tencentMiniGameBackRpc.backRoleRegister(tencentRoleRegisterRpcDTO);
|
|
|
+ gameBackLogService.addLog(user.getId(), gameUserRole.getRoleId(), "腾讯小游戏创角回传提交", JsonUtil.toString(tencentRoleRegisterRpcDTO));
|
|
|
+ }
|
|
|
+ //头条回传
|
|
|
+ if (Objects.equals(agent.getAccountType(), AccountTypeEnum.BYTE.getValue())) {
|
|
|
+ Game game = gameService.getById(user.getGameId());
|
|
|
+ //判断是微信小游戏
|
|
|
+ if (Objects.equals(game.getCategory(), GameCategoryEnum.CATEGORY_WX_APPLET.getId())) {
|
|
|
+ TtRoleRegisterRpcDTO ttRoleRegisterRpcDTO = this.transform(user, agent, gameUserRole, gameApplet);
|
|
|
+ ttMiniGameBackRpc.roleRegisterReport(ttRoleRegisterRpcDTO);
|
|
|
+ gameBackLogService.addLog(user.getId(), gameUserRole.getRoleId(), "头条创角回传提交", JsonUtil.toString(ttRoleRegisterRpcDTO));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("创角回传异常, userId : {}, e : {}", user.getId(), e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void orderCallBack(PlatformOrderDTO platformOrderDTO) {
|
|
|
//判断游戏是否开启广告回传, 未开启, 不回传
|
|
@@ -160,6 +207,40 @@ public class CallBackServiceImpl implements ICallBackService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private TencentRoleRegisterRpcDTO transform(User user, Agent agent, GameApplet gameApplet, GameUserRole gameUserRole) {
|
|
|
+ return TencentRoleRegisterRpcDTO.builder()
|
|
|
+ .backPolicyId(agent.getBackPolicyId())
|
|
|
+ .gameId(gameUserRole.getGameId())
|
|
|
+ .adAccountId(agent.getAccountId())
|
|
|
+ .registerTime(gameUserRole.getCreateTime())
|
|
|
+ .channel(agent.getAgentKey())
|
|
|
+ .wechatOpenid(user.getOpenId())
|
|
|
+ .wechatAppId(gameApplet == null ? null : gameApplet.getAppId())
|
|
|
+ .userActionSetId(agent.getUserActionSetId())
|
|
|
+ .roleId(gameUserRole.getRoleId())
|
|
|
+ .roleName(gameUserRole.getRoleName())
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+
|
|
|
+ private TtRoleRegisterRpcDTO transform(User user, Agent agent, GameUserRole gameUserRole, GameApplet gameApplet) {
|
|
|
+ TtAccountRpcDTO ttAccountRpcDTO = TtAccountRpcDTO.builder()
|
|
|
+ .accountId(agent.getAccountId())
|
|
|
+ .reportToken(agent.getReportToken())
|
|
|
+ .reportUrl(agent.getReportUrl())
|
|
|
+ .build();
|
|
|
+ return TtRoleRegisterRpcDTO.builder()
|
|
|
+ .gameId(gameUserRole.getGameId())
|
|
|
+ .backPolicyId(agent.getBackPolicyId())
|
|
|
+ .accountReport(ttAccountRpcDTO)
|
|
|
+ .wechatAppId(gameApplet == null ? null : gameApplet.getAppId())
|
|
|
+ .wechatOpenId(user.getOpenId())
|
|
|
+ .agentKey(agent.getAgentKey())
|
|
|
+ .roleId(gameUserRole.getRoleId())
|
|
|
+ .roleName(gameUserRole.getRoleName())
|
|
|
+ .registerTime(gameUserRole.getCreateTime())
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+
|
|
|
private TencentUserDTO transform(User user, Agent agent, GameApplet gameApplet) {
|
|
|
return TencentUserDTO.builder()
|
|
|
.backPolicyId(agent.getBackPolicyId())
|
|
@@ -209,6 +290,7 @@ public class CallBackServiceImpl implements ICallBackService {
|
|
|
.orderStatus(platformOrderDTO.getStatus())
|
|
|
.payTime(platformOrderDTO.getPayTime())
|
|
|
.userActionSetId(agent.getUserActionSetId())
|
|
|
+ .roleId(platformOrderDTO.getRoleId())
|
|
|
.roleName(platformOrderDTO.getRoleName())
|
|
|
.build();
|
|
|
}
|
|
@@ -232,6 +314,7 @@ public class CallBackServiceImpl implements ICallBackService {
|
|
|
.createTime(platformOrderDTO.getCreateTime())
|
|
|
.payTime(platformOrderDTO.getPayTime())
|
|
|
.regTime(regTime)
|
|
|
+ .roleId(platformOrderDTO.getRoleId())
|
|
|
.roleName(platformOrderDTO.getRoleName())
|
|
|
.build();
|
|
|
}
|