|
@@ -7,6 +7,7 @@ import com.zanxiang.game.module.mybatis.entity.UserVisitLog;
|
|
import com.zanxiang.game.module.mybatis.mapper.UserVisitLogMapper;
|
|
import com.zanxiang.game.module.mybatis.mapper.UserVisitLogMapper;
|
|
import com.zanxiang.game.module.sdk.service.IAgentService;
|
|
import com.zanxiang.game.module.sdk.service.IAgentService;
|
|
import com.zanxiang.game.module.sdk.service.IUserVisitLogService;
|
|
import com.zanxiang.game.module.sdk.service.IUserVisitLogService;
|
|
|
|
+import com.zanxiang.module.util.JsonUtil;
|
|
import com.zanxiang.module.web.util.IpUtil;
|
|
import com.zanxiang.module.web.util.IpUtil;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.logging.log4j.util.Strings;
|
|
import org.apache.logging.log4j.util.Strings;
|
|
@@ -36,19 +37,25 @@ public class UserVisitLogServiceImpl extends ServiceImpl<UserVisitLogMapper, Use
|
|
public boolean visitLogCreate(String url, String userAgent, HttpServletRequest httpServletRequest) {
|
|
public boolean visitLogCreate(String url, String userAgent, HttpServletRequest httpServletRequest) {
|
|
//解析url
|
|
//解析url
|
|
Map<String, String> urlParamMap = this.getUrlParameter(url);
|
|
Map<String, String> urlParamMap = this.getUrlParameter(url);
|
|
|
|
+ log.error("下载地址访问上报参数 urlParamMap : {}", JsonUtil.toString(urlParamMap));
|
|
//获取渠道标识
|
|
//获取渠道标识
|
|
- String state = urlParamMap.get("agentId");
|
|
|
|
- if (Strings.isBlank(state)) {
|
|
|
|
- state = urlParamMap.get("agentKey");
|
|
|
|
|
|
+ Agent agent = null;
|
|
|
|
+ String agentId = urlParamMap.get("agentId");
|
|
|
|
+ String agentKey = urlParamMap.get("agentKey");
|
|
|
|
+ if (Strings.isNotBlank(agentId)) {
|
|
|
|
+ agent = agentService.getById(agentId);
|
|
|
|
+ }
|
|
|
|
+ if (agent == null && Strings.isNotBlank(agentKey)) {
|
|
|
|
+ agent = agentService.getOne(new LambdaQueryWrapper<Agent>().eq(Agent::getAgentKey, agentKey));
|
|
|
|
+ }
|
|
|
|
+ //判断是否存在渠道
|
|
|
|
+ if (agent == null) {
|
|
|
|
+ return Boolean.FALSE;
|
|
}
|
|
}
|
|
- final String agentSign = state;
|
|
|
|
- //查询渠道信息
|
|
|
|
- Agent agent = agentService.getOne(new LambdaQueryWrapper<Agent>()
|
|
|
|
- .and(qw -> qw.eq(Agent::getAgentKey, agentSign).or().eq(Agent::getId, agentSign)));
|
|
|
|
//保存访问记录
|
|
//保存访问记录
|
|
return super.save(UserVisitLog.builder()
|
|
return super.save(UserVisitLog.builder()
|
|
- .gameId(agent == null ? null : agent.getGameId())
|
|
|
|
- .agentId(agent == null ? null : agent.getId())
|
|
|
|
|
|
+ .gameId(agent.getGameId())
|
|
|
|
+ .agentId(agent.getId())
|
|
.ip(IpUtil.getRealIp(httpServletRequest))
|
|
.ip(IpUtil.getRealIp(httpServletRequest))
|
|
.ua(userAgent)
|
|
.ua(userAgent)
|
|
.url(urlParamMap.get("url"))
|
|
.url(urlParamMap.get("url"))
|