|
@@ -6,6 +6,7 @@ import com.zanxiang.game.back.base.ServerInfo;
|
|
|
import com.zanxiang.game.back.base.pojo.dto.*;
|
|
|
import com.zanxiang.game.back.base.rpc.ITencentMiniGameBackRpc;
|
|
|
import com.zanxiang.game.back.base.rpc.ITencentUserActionBackRpc;
|
|
|
+import com.zanxiang.game.back.base.rpc.ITtAppBackRpc;
|
|
|
import com.zanxiang.game.back.base.rpc.ITtMiniGameBackRpc;
|
|
|
import com.zanxiang.game.module.base.pojo.enums.AccountTypeEnum;
|
|
|
import com.zanxiang.game.module.base.pojo.enums.GameCategoryEnum;
|
|
@@ -16,7 +17,6 @@ import com.zanxiang.game.module.sdk.pojo.param.CallBackControlParam;
|
|
|
import com.zanxiang.game.module.sdk.pojo.param.UserData;
|
|
|
import com.zanxiang.game.module.sdk.service.*;
|
|
|
import com.zanxiang.module.util.JsonUtil;
|
|
|
-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;
|
|
@@ -45,6 +45,9 @@ public class CallBackServiceImpl implements ICallBackService {
|
|
|
@DubboReference(providedBy = ServerInfo.SERVER_DUBBO_NAME)
|
|
|
private ITtMiniGameBackRpc ttMiniGameBackRpc;
|
|
|
|
|
|
+ @DubboReference(providedBy = ServerInfo.SERVER_DUBBO_NAME)
|
|
|
+ private ITtAppBackRpc ttAppBackRpc;
|
|
|
+
|
|
|
@Autowired
|
|
|
private IAgentService agentService;
|
|
|
|
|
@@ -65,18 +68,51 @@ public class CallBackServiceImpl implements ICallBackService {
|
|
|
|
|
|
@Override
|
|
|
public boolean callBackJudge(CallBackControlParam param, UserData userData) {
|
|
|
-
|
|
|
log.error("事件回传判断, param : {}, userData : {}", JsonUtil.toString(param), JsonUtil.toString(userData));
|
|
|
-
|
|
|
+ //事件类型枚举
|
|
|
CallBackTypeEnum callBackTypeEnum = param.getCallBackTypeEnum();
|
|
|
- if (Objects.equals(callBackTypeEnum, CallBackTypeEnum.CALL_BACK_PAY_ORDER) && Strings.isBlank(param.getOrderId())) {
|
|
|
- throw new BaseException("参数错误, 下单或者支付行为缺少订单id");
|
|
|
+ //查询玩家
|
|
|
+ User user = userService.getById(userData.getUserId());
|
|
|
+ //不存在渠道
|
|
|
+ Agent agent = agentService.getById(user.getAgentId());
|
|
|
+ if (agent == null) {
|
|
|
+ log.error("事件回传判断, 渠道信息不存在, param : {}, userData : {}", JsonUtil.toString(param), JsonUtil.toString(userData));
|
|
|
+ return Boolean.FALSE;
|
|
|
}
|
|
|
- //todo : 接入策略判断方法
|
|
|
- boolean b = userData.getUserId() % 2 == 0;
|
|
|
-
|
|
|
- log.error("事件回传判断返回, b : {}", b);
|
|
|
- return b;
|
|
|
+ try {
|
|
|
+ //注册(新创建账号)
|
|
|
+ if (Objects.equals(callBackTypeEnum, CallBackTypeEnum.CALL_BACK_REGISTER)) {
|
|
|
+ TtAppUserBackQueryRpcDTO transform = this.transform(user.getId(), agent);
|
|
|
+ return ttAppBackRpc.userBackQuery(transform).getData();
|
|
|
+ }
|
|
|
+ //激活(创建角色)
|
|
|
+ if (Objects.equals(callBackTypeEnum, CallBackTypeEnum.CALL_BACK_ACTIVATE)) {
|
|
|
+ if (Strings.isBlank(param.getRoleId())) {
|
|
|
+ log.error("事件回传判断, 角色Id参数不存在, param : {}, userData : {}", JsonUtil.toString(param), JsonUtil.toString(userData));
|
|
|
+ return Boolean.FALSE;
|
|
|
+ }
|
|
|
+ TtAppRoleRegisterBackQueryRpcDTO transform = this.transform(user.getId(), agent, param.getRoleId());
|
|
|
+ return ttAppBackRpc.roleRegisterBackQuery(transform).getData();
|
|
|
+ }
|
|
|
+ //登录(老账号登录)
|
|
|
+ if (Objects.equals(callBackTypeEnum, CallBackTypeEnum.CALL_BACK_LOGIN_IN)) {
|
|
|
+ log.error("事件回传判断, 账号登录不回传, param : {}, userData : {}", JsonUtil.toString(param), JsonUtil.toString(userData));
|
|
|
+ return Boolean.FALSE;
|
|
|
+ }
|
|
|
+ //支付
|
|
|
+ if (Objects.equals(callBackTypeEnum, CallBackTypeEnum.CALL_BACK_PAY_ORDER)) {
|
|
|
+ if (Strings.isBlank(param.getRoleId())) {
|
|
|
+ log.error("事件回传判断, 订单Id参数不存在, param : {}, userData : {}", JsonUtil.toString(param), JsonUtil.toString(userData));
|
|
|
+ return Boolean.FALSE;
|
|
|
+ }
|
|
|
+ TtAppOrderBackQueryRpcDTO transform = this.transform(user.getId(), param.getOrderId(), agent);
|
|
|
+ return ttAppBackRpc.orderBackQuery(transform).getData();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("事件回传判断, 出现异常, param : {}, userData : {}, e : {}", JsonUtil.toString(param),
|
|
|
+ JsonUtil.toString(userData), e.getMessage(), e);
|
|
|
+ }
|
|
|
+ return Boolean.FALSE;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -126,6 +162,12 @@ public class CallBackServiceImpl implements ICallBackService {
|
|
|
gameBackLogService.addLog(user.getId(), null, "头条用户回传提交", JsonUtil.toString(activeReportRpcDTO));
|
|
|
}
|
|
|
}
|
|
|
+ //头条APP直投回传
|
|
|
+ if (CollectionUtils.isNotEmpty(urlParamMap) && Objects.equals(agent.getAccountType(), AccountTypeEnum.BYTE_APP.getValue())) {
|
|
|
+ TtUserActiveAppRpcDTO ttUserActiveAppRpcDTO = this.transform(user, agent);
|
|
|
+ ttAppBackRpc.userActiveReport(ttUserActiveAppRpcDTO);
|
|
|
+ gameBackLogService.addLog(user.getId(), null, "头条APP用户回传提交", JsonUtil.toString(ttUserActiveAppRpcDTO));
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
|
log.error("用户回传异常, userId : {}, e : {}", user.getId(), e.getMessage());
|
|
|
}
|
|
@@ -172,6 +214,12 @@ public class CallBackServiceImpl implements ICallBackService {
|
|
|
gameBackLogService.addLog(user.getId(), gameUserRole.getRoleId(), "头条创角回传提交", JsonUtil.toString(ttRoleRegisterRpcDTO));
|
|
|
}
|
|
|
}
|
|
|
+ //头条APP直投回传
|
|
|
+ if (Objects.equals(agent.getAccountType(), AccountTypeEnum.BYTE_APP.getValue())) {
|
|
|
+ TtRoleRegisterAppRpcDTO ttRoleRegisterAppRpcDTO = this.transform(user, agent, gameUserRole);
|
|
|
+ ttAppBackRpc.roleRegisterReport(ttRoleRegisterAppRpcDTO);
|
|
|
+ gameBackLogService.addLog(user.getId(), gameUserRole.getRoleId(), "头条APP创角回传提交", JsonUtil.toString(ttRoleRegisterAppRpcDTO));
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
|
log.error("创角回传异常, userId : {}, e : {}", user.getId(), e.getMessage());
|
|
|
}
|
|
@@ -222,6 +270,12 @@ public class CallBackServiceImpl implements ICallBackService {
|
|
|
gameBackLogService.addLog(user.getId(), platformOrderDTO.getOrderId(), "头条订单回传提交", JsonUtil.toString(ttOrderRpcDTO));
|
|
|
}
|
|
|
}
|
|
|
+ //头条APP直投回传
|
|
|
+ if (Objects.equals(agent.getAccountType(), AccountTypeEnum.BYTE_APP.getValue())) {
|
|
|
+ TtOrderAppRpcDTO ttOrderAppRpcDTO = this.transform(platformOrderDTO, user, agent);
|
|
|
+ ttAppBackRpc.orderReport(ttOrderAppRpcDTO);
|
|
|
+ gameBackLogService.addLog(user.getId(), platformOrderDTO.getOrderId(), "头条APP订单回传提交", JsonUtil.toString(ttOrderAppRpcDTO));
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
|
log.error("订单回传异常, orderId : {}, e : {}", platformOrderDTO.getOrderId(), e.getMessage());
|
|
|
}
|
|
@@ -332,4 +386,90 @@ public class CallBackServiceImpl implements ICallBackService {
|
|
|
.reportUrl(agent.getReportUrl())
|
|
|
.build();
|
|
|
}
|
|
|
+
|
|
|
+ private TtUserActiveAppRpcDTO transform(User user, Agent agent) {
|
|
|
+ return TtUserActiveAppRpcDTO.builder()
|
|
|
+ .gameId(agent.getGameId())
|
|
|
+ .accountReport(this.transform(agent))
|
|
|
+ .agentKey(agent.getAgentKey())
|
|
|
+ .activeTime(user.getCreateTime())
|
|
|
+ .backPolicyId(agent.getBackPolicyId())
|
|
|
+ .userId(user.getId().toString())
|
|
|
+ .mac(user.getMac())
|
|
|
+ .imei(user.getImei())
|
|
|
+ .oaid(user.getOaid())
|
|
|
+ .androidId(user.getAndroidId())
|
|
|
+ .idfa(user.getIdfa())
|
|
|
+ .caid(user.getCaid())
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+
|
|
|
+ private TtOrderAppRpcDTO transform(PlatformOrderDTO platformOrderDTO, User user, Agent agent) {
|
|
|
+ return TtOrderAppRpcDTO.builder()
|
|
|
+ .gameId(agent.getGameId())
|
|
|
+ .accountReport(this.transform(agent))
|
|
|
+ .userId(user.getId().toString())
|
|
|
+ .orderId(platformOrderDTO.getOrderId())
|
|
|
+ .agentKey(agent.getAgentKey())
|
|
|
+ .backPolicyId(agent.getBackPolicyId())
|
|
|
+ .rechargeMoney(platformOrderDTO.getAmount().longValue() * 100)
|
|
|
+ .orderStatus(platformOrderDTO.getStatus())
|
|
|
+ .regTime(user.getCreateTime())
|
|
|
+ .createTime(platformOrderDTO.getCreateTime())
|
|
|
+ .payTime(platformOrderDTO.getPayTime())
|
|
|
+ .roleId(platformOrderDTO.getRoleId())
|
|
|
+ .roleName(platformOrderDTO.getRoleName())
|
|
|
+ .mac(user.getMac())
|
|
|
+ .imei(user.getImei())
|
|
|
+ .oaid(user.getOaid())
|
|
|
+ .androidId(user.getAndroidId())
|
|
|
+ .idfa(user.getIdfa())
|
|
|
+ .caid(user.getCaid())
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+
|
|
|
+ private TtRoleRegisterAppRpcDTO transform(User user, Agent agent, GameUserRole gameUserRole) {
|
|
|
+ return TtRoleRegisterAppRpcDTO.builder()
|
|
|
+ .gameId(agent.getGameId())
|
|
|
+ .userId(user.getId().toString())
|
|
|
+ .backPolicyId(agent.getBackPolicyId())
|
|
|
+ .accountReport(this.transform(agent))
|
|
|
+ .agentKey(agent.getAgentKey())
|
|
|
+ .roleId(gameUserRole.getRoleId())
|
|
|
+ .roleName(gameUserRole.getRoleName())
|
|
|
+ .registerTime(gameUserRole.getCreateTime())
|
|
|
+ .mac(user.getMac())
|
|
|
+ .imei(user.getImei())
|
|
|
+ .oaid(user.getOaid())
|
|
|
+ .androidId(user.getAndroidId())
|
|
|
+ .idfa(user.getIdfa())
|
|
|
+ .caid(user.getCaid())
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+
|
|
|
+ private TtAppUserBackQueryRpcDTO transform(Long userId, Agent agent) {
|
|
|
+ return TtAppUserBackQueryRpcDTO.builder()
|
|
|
+ .gameId(agent.getGameId())
|
|
|
+ .userId(userId.toString())
|
|
|
+ .agentKey(agent.getAgentKey())
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+
|
|
|
+ private TtAppOrderBackQueryRpcDTO transform(Long userId, String orderId, Agent agent) {
|
|
|
+ return TtAppOrderBackQueryRpcDTO.builder()
|
|
|
+ .gameId(agent.getGameId())
|
|
|
+ .userId(userId.toString())
|
|
|
+ .orderId(orderId)
|
|
|
+ .agentKey(agent.getAgentKey())
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+
|
|
|
+ private TtAppRoleRegisterBackQueryRpcDTO transform(Long userId, Agent agent, String roleId) {
|
|
|
+ return TtAppRoleRegisterBackQueryRpcDTO.builder()
|
|
|
+ .gameId(agent.getGameId())
|
|
|
+ .userId(userId.toString())
|
|
|
+ .agentKey(agent.getAgentKey())
|
|
|
+ .roleId(roleId)
|
|
|
+ .build();
|
|
|
+ }
|
|
|
}
|