|
@@ -95,48 +95,26 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Tuple3<Long, Map<String, String>, String> getUserAgentId(String channel) {
|
|
|
- log.error("用户注册接收到的渠道参数 channel : {}", channel);
|
|
|
- if (Strings.isBlank(channel)) {
|
|
|
- return Tuples.of(0L, Collections.emptyMap(), Strings.EMPTY);
|
|
|
- }
|
|
|
- //数据解析
|
|
|
- Map<String, String> urlParamMap = this.channelTransform(channel);
|
|
|
- String shareUserId = urlParamMap.get("shareUserId");
|
|
|
- //查询渠道
|
|
|
- Agent agent = null;
|
|
|
- if (Strings.isNotBlank(shareUserId)) {
|
|
|
- User user = userService.getById(Long.valueOf(shareUserId));
|
|
|
- if (user != null) {
|
|
|
- agent = super.getById(user.getAgentId());
|
|
|
- }
|
|
|
- } else {
|
|
|
- agent = this.getAgentByKey(urlParamMap);
|
|
|
- }
|
|
|
- if (agent == null) {
|
|
|
- return Tuples.of(0L, Collections.emptyMap(), Strings.isBlank(shareUserId) ? Strings.EMPTY : shareUserId);
|
|
|
- }
|
|
|
- return Tuples.of(agent.getId(), urlParamMap, Strings.isBlank(shareUserId) ? Strings.EMPTY : shareUserId);
|
|
|
- }
|
|
|
-
|
|
|
public Tuple3<Long, Map<String, String>, String> getUserAgentId(UserData userData) {
|
|
|
+ log.error("用户注册接收到的渠道参数 userData : {}", JsonUtil.toString(userData));
|
|
|
+ //获取游戏信息
|
|
|
GameExt gameExt = gameExtService.getByGameId(userData.getGameId());
|
|
|
Game game = gameService.getById(userData.getGameId());
|
|
|
- String channel = userData.getChannel();
|
|
|
-
|
|
|
+ //不投放得APP游戏按ip和ua进行渠道匹配
|
|
|
if (Objects.equals(game.getCategory(), GameCategoryEnum.CATEGORY_APP.getId())
|
|
|
- && !Objects.equals(gameExt.getAdCallBackSwitch(), Boolean.TRUE)){
|
|
|
-
|
|
|
+ && !Objects.equals(gameExt.getAdCallBackSwitch(), Boolean.TRUE)) {
|
|
|
+ UserVisitLog userVisitLog = this.getUserVisitLog(userData);
|
|
|
+ if (userVisitLog == null) {
|
|
|
+ return Tuples.of(0L, Collections.emptyMap(), Strings.EMPTY);
|
|
|
+ }
|
|
|
+ return Tuples.of(userVisitLog.getAgentId(), Collections.emptyMap(), Strings.EMPTY);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- log.error("用户注册接收到的渠道参数 channel : {}", channel);
|
|
|
- if (Strings.isBlank(channel)) {
|
|
|
+ //链接参数
|
|
|
+ if (Strings.isBlank(userData.getChannel())) {
|
|
|
return Tuples.of(0L, Collections.emptyMap(), Strings.EMPTY);
|
|
|
}
|
|
|
//数据解析
|
|
|
- Map<String, String> urlParamMap = this.channelTransform(channel);
|
|
|
+ Map<String, String> urlParamMap = this.channelTransform(userData.getChannel());
|
|
|
String shareUserId = urlParamMap.get("shareUserId");
|
|
|
//查询渠道
|
|
|
Agent agent = null;
|
|
@@ -149,25 +127,19 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
|
|
|
agent = this.getAgentByKey(urlParamMap);
|
|
|
}
|
|
|
if (agent == null) {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
return Tuples.of(0L, Collections.emptyMap(), Strings.isBlank(shareUserId) ? Strings.EMPTY : shareUserId);
|
|
|
}
|
|
|
return Tuples.of(agent.getId(), urlParamMap, Strings.isBlank(shareUserId) ? Strings.EMPTY : shareUserId);
|
|
|
}
|
|
|
|
|
|
- public Long getUserAgentIda(UserData userData) {
|
|
|
+ private UserVisitLog getUserVisitLog(UserData userData) {
|
|
|
//当前时间
|
|
|
LocalDateTime regTime = LocalDateTime.now();
|
|
|
// 0. 优先前置策略, 单独判断ip是否只有一个用户, 只有一个用户则是该用户
|
|
|
List<UserVisitLog> userVisitLogList = userVisitLogService.list(new LambdaQueryWrapper<UserVisitLog>()
|
|
|
.eq(UserVisitLog::getIp, userData.getIp()));
|
|
|
if (CollectionUtils.isNotEmpty(userVisitLogList) && userVisitLogList.size() == 1) {
|
|
|
- return userVisitLogList.get(0).getAgentId();
|
|
|
+ return userVisitLogList.get(0);
|
|
|
}
|
|
|
// 1. 策略一 : 根据 ip + ua 精准匹配用户
|
|
|
userVisitLogList = userVisitLogService.list(new LambdaQueryWrapper<UserVisitLog>()
|
|
@@ -176,8 +148,7 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
|
|
|
.le(UserVisitLog::getCreateTime, regTime));
|
|
|
// 判断通过策略一是否拿到数据, 筛选出访问时间与注册时间最接近的
|
|
|
if (CollectionUtils.isNotEmpty(userVisitLogList)) {
|
|
|
- UserVisitLog lastUserCall = this.getLastUserCall(userVisitLogList, regTime);
|
|
|
- return lastUserCall == null ? null : lastUserCall.getAgentId();
|
|
|
+ return this.getLastUserCall(userVisitLogList, regTime);
|
|
|
}
|
|
|
// 2. 策略二 : 根据 ip + regTime 模糊匹配用户, 数据误差在15分钟以内
|
|
|
userVisitLogList = userVisitLogService.list(new LambdaQueryWrapper<UserVisitLog>()
|
|
@@ -186,8 +157,7 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
|
|
|
.le(UserVisitLog::getCreateTime, regTime));
|
|
|
// 判断通过策略二是否拿到数据, 筛选出访问时间与注册时间最接近的
|
|
|
if (CollectionUtils.isNotEmpty(userVisitLogList)) {
|
|
|
- UserVisitLog lastUserCall = this.getLastUserCall(userVisitLogList, regTime);
|
|
|
- return lastUserCall == null ? null : lastUserCall.getAgentId();
|
|
|
+ return this.getLastUserCall(userVisitLogList, regTime);
|
|
|
}
|
|
|
// 3. 策略三 : 根据 ua + regTime 模糊匹配用户, 数据误差在15分钟以内
|
|
|
userVisitLogList = userVisitLogService.list(new LambdaQueryWrapper<UserVisitLog>()
|
|
@@ -196,16 +166,14 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
|
|
|
.le(UserVisitLog::getCreateTime, regTime));
|
|
|
// 判断通过策略三是否拿到数据, 筛选出访问时间与注册时间最接近的
|
|
|
if (CollectionUtils.isNotEmpty(userVisitLogList)) {
|
|
|
- UserVisitLog lastUserCall = this.getLastUserCall(userVisitLogList, regTime);
|
|
|
- return lastUserCall == null ? null : lastUserCall.getAgentId();
|
|
|
+ return this.getLastUserCall(userVisitLogList, regTime);
|
|
|
}
|
|
|
// 4. 策略四 : 根据 regTime 模糊匹配用户, 数据误差在15分钟以内, 此策略为兜底策略
|
|
|
userVisitLogList = userVisitLogService.list(new LambdaQueryWrapper<UserVisitLog>()
|
|
|
.ge(UserVisitLog::getCreateTime, regTime.minusMinutes(15))
|
|
|
.le(UserVisitLog::getCreateTime, regTime));
|
|
|
if (CollectionUtils.isNotEmpty(userVisitLogList)) {
|
|
|
- UserVisitLog lastUserCall = this.getLastUserCall(userVisitLogList, regTime);
|
|
|
- return lastUserCall == null ? null : lastUserCall.getAgentId();
|
|
|
+ return this.getLastUserCall(userVisitLogList, regTime);
|
|
|
}
|
|
|
return null;
|
|
|
}
|