|
@@ -1,7 +1,6 @@
|
|
|
package com.zanxiang.game.module.sdk.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.github.sd4324530.jtuple.Tuple2;
|
|
|
import com.github.sd4324530.jtuple.Tuple3;
|
|
@@ -77,27 +76,19 @@ public class GameBackLogMediaSdkServiceImpl extends ServiceImpl<GameBackLogMedia
|
|
|
resultMap.put("userId", userData.getUserId());
|
|
|
resultMap.put("gameId", userData.getGameId());
|
|
|
resultMap.put("callBack", Boolean.FALSE);
|
|
|
- //参数判断是否齐全
|
|
|
- Tuple2<Boolean, String> backParamCheck = this.callBackParamCheck(param, resultMap);
|
|
|
- if (!backParamCheck.first) {
|
|
|
- resultMap.put("backMsg", backParamCheck.second);
|
|
|
+ //查询玩家信息
|
|
|
+ User user = userService.getById(userData.getUserId());
|
|
|
+ //参数判断和测试账号判断
|
|
|
+ if (!this.callBackParamCheck(param, resultMap) || this.userEventTest(param, user, resultMap)) {
|
|
|
return resultMap;
|
|
|
}
|
|
|
- //判断是否过事件行为, 全量回传
|
|
|
- Tuple2<Boolean, List<Integer>> userEventTuple = this.userEventTest(userData, param.getOrderId());
|
|
|
- if (userEventTuple.first) {
|
|
|
- resultMap.put("callBack", Boolean.TRUE);
|
|
|
- if (CollectionUtils.isNotEmpty(userEventTuple.second)) {
|
|
|
- resultMap.put("amount", userEventTuple.second);
|
|
|
- }
|
|
|
- return resultMap;
|
|
|
- }
|
|
|
- //查询玩家, 判断玩家是否存在渠道, 不存在渠道则不回传
|
|
|
- User user = userService.getById(userData.getUserId());
|
|
|
- Agent agent = agentService.getById(user.getAgentId());
|
|
|
- if (agent == null) {
|
|
|
+ //玩家渠道信息回传检测
|
|
|
+ Tuple2<Boolean, Agent> userAgentCheckTuple2 = this.userAgentCheck(user, resultMap);
|
|
|
+ if (!userAgentCheckTuple2.first) {
|
|
|
return resultMap;
|
|
|
}
|
|
|
+ //渠道
|
|
|
+ Agent agent = userAgentCheckTuple2.second;
|
|
|
//线程锁
|
|
|
String lockKey = this.getLockKey(param, userData.getUserId());
|
|
|
//上锁
|
|
@@ -133,7 +124,7 @@ public class GameBackLogMediaSdkServiceImpl extends ServiceImpl<GameBackLogMedia
|
|
|
return lockKey;
|
|
|
}
|
|
|
|
|
|
- private Tuple2<Boolean, String> callBackParamCheck(CallBackControlParam param, Map<String, Object> resultMap) {
|
|
|
+ private boolean callBackParamCheck(CallBackControlParam param, Map<String, Object> resultMap) {
|
|
|
CallBackTypeEnum callBackTypeEnum = param.getCallBackTypeEnum();
|
|
|
//创角, 新手引导, 等级提升回传, 必须传角色id
|
|
|
if (Objects.equals(callBackTypeEnum, CallBackTypeEnum.CALL_BACK_ACTIVATE)
|
|
@@ -141,44 +132,66 @@ public class GameBackLogMediaSdkServiceImpl extends ServiceImpl<GameBackLogMedia
|
|
|
|| Objects.equals(callBackTypeEnum, CallBackTypeEnum.CALL_BACK_TUTORIAL_FINISH)
|
|
|
|| Objects.equals(callBackTypeEnum, CallBackTypeEnum.CALL_BACK_UPDATE_LEVEL)) {
|
|
|
if (Strings.isBlank(param.getRoleId())) {
|
|
|
- return Tuple2.with(Boolean.FALSE, "参数错误, 创角, 新手引导或者等级提升回传, 必须传角色id");
|
|
|
+ resultMap.put("backMsg", "参数错误, 创角, 新手引导或者等级提升回传, 必须传角色id");
|
|
|
+ return false;
|
|
|
}
|
|
|
resultMap.put("roleId", param.getRoleId());
|
|
|
}
|
|
|
//付费回传, 必须传订单id
|
|
|
if (Objects.equals(callBackTypeEnum, CallBackTypeEnum.CALL_BACK_PAY_ORDER)) {
|
|
|
if (Strings.isBlank(param.getOrderId())) {
|
|
|
- return Tuple2.with(Boolean.FALSE, "参数错误, 付费回传, 必须传订单id");
|
|
|
+ resultMap.put("backMsg", "参数错误, 付费回传, 必须传订单id");
|
|
|
+ return false;
|
|
|
}
|
|
|
resultMap.put("orderId", param.getOrderId());
|
|
|
}
|
|
|
- return Tuple2.with(Boolean.TRUE, null);
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
- private Tuple2<Boolean, List<Integer>> userEventTest(UserData userData, String orderId) {
|
|
|
- Boolean callBack = Boolean.FALSE;
|
|
|
- List<Integer> amountList = null;
|
|
|
- //查询玩家
|
|
|
- User user = userService.getById(userData.getUserId());
|
|
|
+ private boolean userEventTest(CallBackControlParam param, User user, Map<String, Object> resultMap) {
|
|
|
//判断是否测试过事件用户
|
|
|
if (userEventService.count(new LambdaQueryWrapper<UserEvent>()
|
|
|
- .eq(UserEvent::getGameId, userData.getGameId())
|
|
|
+ .eq(UserEvent::getGameId, user.getGameId())
|
|
|
.and(qw -> qw.eq(UserEvent::getUsername, user.getUsername())
|
|
|
.or().eq(UserEvent::getUsername, user.getOpenId())
|
|
|
- .or().eq(UserEvent::getMobile, user.getMobile())
|
|
|
- )
|
|
|
- ) > 0) {
|
|
|
- callBack = Boolean.TRUE;
|
|
|
+ .or().eq(UserEvent::getMobile, user.getMobile()))
|
|
|
+ ) <= 0) {
|
|
|
+ return false;
|
|
|
}
|
|
|
- //判断是否订单回传
|
|
|
- if (callBack && Strings.isNotBlank(orderId)) {
|
|
|
- PlatformOrderDTO platformOrderDTO = orderService.getByOrderId(orderId);
|
|
|
+ //测试账号, 回传默认全量回传, 不做判断
|
|
|
+ resultMap.put("callBack", Boolean.TRUE);
|
|
|
+ resultMap.put("backMsg", "测试账号, 回传默认全量回传, 不做判断");
|
|
|
+ //回传类型
|
|
|
+ CallBackTypeEnum callBackTypeEnum = param.getCallBackTypeEnum();
|
|
|
+ //判断是否沉默唤起回传, 添加沉默唤起判断天数
|
|
|
+ if (Objects.equals(callBackTypeEnum, CallBackTypeEnum.CALL_BACK_RE_ACTIVE)) {
|
|
|
+ resultMap.put("backFlowDay", 30);
|
|
|
+ }
|
|
|
+ //判断是否订单付费回传, 添加回传金额
|
|
|
+ if (Objects.equals(callBackTypeEnum, CallBackTypeEnum.CALL_BACK_PAY_ORDER) && Strings.isNotBlank(param.getOrderId())) {
|
|
|
+ PlatformOrderDTO platformOrderDTO = orderService.getByOrderId(param.getOrderId());
|
|
|
if (platformOrderDTO != null) {
|
|
|
- amountList = Collections.singletonList(platformOrderDTO.getAmount().intValue());
|
|
|
+ resultMap.put("amount", Collections.singletonList(platformOrderDTO.getAmount().intValue()));
|
|
|
}
|
|
|
}
|
|
|
//返回结果
|
|
|
- return Tuple2.with(callBack, amountList);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Tuple2<Boolean, Agent> userAgentCheck(User user, Map<String, Object> resultMap) {
|
|
|
+ //判断玩家是否为自然量或者被分享用户, 是则不执行回传
|
|
|
+ if (Objects.equals(user.getAgentId(), Agent.DEFAULT_AGENT) || user.getShareUserId() != null) {
|
|
|
+ resultMap.put("backMsg", "玩家属于自然量或者被分享用户, 不回传");
|
|
|
+ return Tuple2.with(Boolean.FALSE, null);
|
|
|
+ }
|
|
|
+ //判断玩家是否存在渠道, 不存在渠道则不回传
|
|
|
+ Agent agent = agentService.getById(user.getAgentId());
|
|
|
+ if (agent == null) {
|
|
|
+ resultMap.put("backMsg", "根据玩家渠道id查询渠道信息为空, 无法执行回传");
|
|
|
+ return Tuple2.with(Boolean.FALSE, null);
|
|
|
+ }
|
|
|
+ //返回执行回传, 且返回渠道信息
|
|
|
+ return Tuple2.with(Boolean.TRUE, agent);
|
|
|
}
|
|
|
|
|
|
private void checkCallBack(User user, Agent agent, Map<String, Object> resultMap, CallBackControlParam param) {
|
|
@@ -239,7 +252,7 @@ public class GameBackLogMediaSdkServiceImpl extends ServiceImpl<GameBackLogMedia
|
|
|
//获取玩家今天之前最后一次登录日志
|
|
|
UserLoginLog userLoginLog = userLoginLogService.getOne(new LambdaQueryWrapper<UserLoginLog>()
|
|
|
.eq(UserLoginLog::getUserId, userId)
|
|
|
- .le(UserLoginLog::getCreateTime, LocalDateTime.of(LocalDate.now(), LocalTime.MIN))
|
|
|
+ .lt(UserLoginLog::getCreateTime, LocalDateTime.of(LocalDate.now(), LocalTime.MIN))
|
|
|
.orderByDesc(UserLoginLog::getCreateTime)
|
|
|
.last("limit 1"));
|
|
|
if (userLoginLog == null) {
|