...
|
...
|
@@ -53,10 +53,13 @@ public class UnionServiceImpl implements IUnionService { |
|
|
static Logger activeUnion = LoggerFactory.getLogger("activeUnion");
|
|
|
|
|
|
static Logger clickUnion = LoggerFactory.getLogger("clickUnion");
|
|
|
|
|
|
|
|
|
static Logger ipMatch = LoggerFactory.getLogger("ipMatch");
|
|
|
|
|
|
private static final String UNION_KEY = "UNION:KEY:";
|
|
|
|
|
|
static Logger log = LoggerFactory.getLogger(UnionServiceImpl.class);
|
|
|
|
|
|
|
|
|
@Resource(name="yhRedisTemplate")
|
|
|
YHRedisTemplate<String, String> yHRedisTemplate;
|
...
|
...
|
@@ -177,14 +180,12 @@ public class UnionServiceImpl implements IUnionService { |
|
|
|
|
|
|
|
|
//把IP作为key,也保存到redis
|
|
|
// key = UNION_KEY + "_" + request.getClientIp() + "_" + request.getAppkey();
|
|
|
// yhValueOperations.set(key, JSON.toJSONString(request));
|
|
|
// yHRedisTemplate.longExpire(key, activeTime.get(), TimeUnit.HOURS);
|
|
|
// log.info("clickUnion set redis second success. with key={}, value={}", key, JSON.toJSONString(request));
|
|
|
|
|
|
|
|
|
key = UNION_KEY + "_" + request.getClientIp() + "_" + request.getAppkey();
|
|
|
yhValueOperations.set(key, JSON.toJSONString(request));
|
|
|
yHRedisTemplate.longExpire(key, activeTime.get(), TimeUnit.HOURS);
|
|
|
log.info("clickUnion set redis second success. with key={}, value={}", key, JSON.toJSONString(request));
|
|
|
|
|
|
log.info("clickUnion set redis success with request={}", request);
|
|
|
// log.info("clickUnion set redis success with request={}", request);
|
|
|
|
|
|
// if (union != null) {
|
|
|
// //如果90天以内,已经存在点击记录,则不需要插入或更新数据库
|
...
|
...
|
@@ -284,35 +285,29 @@ public class UnionServiceImpl implements IUnionService { |
|
|
}
|
|
|
|
|
|
log.info("activateUnion with get redis first with key={}, value={}", key, value);
|
|
|
clickUnion.info("activateUnion with get redis first with key={}, value={}", key, value);
|
|
|
if (StringUtils.isNotEmpty(request.getTd())) {
|
|
|
activeUnion.info("activateUnion with get redis first with key={}, value={}", key, value);
|
|
|
String td = request.getTd();
|
|
|
if (StringUtils.isNotEmpty(td)) {
|
|
|
if (StringUtils.isEmpty(value)) {
|
|
|
key = UNION_KEY + "_" + request.getClientIp() + "_" + request.getTd() + "_" + request.getAppkey();
|
|
|
key = UNION_KEY + "_" + request.getClientIp() + "_" + td + "_" + request.getAppkey();
|
|
|
value = yhValueOperations.get(key);
|
|
|
log.info("activateUnion with get redis first with key={}, value={}", key, value);
|
|
|
}
|
|
|
if (StringUtils.isEmpty(value)) {
|
|
|
String[] arr = request.getTd().split("_");
|
|
|
if (arr.length > 3) {
|
|
|
request.setTd(arr[2] + "_" + arr[3]);
|
|
|
key = UNION_KEY + "_" + request.getClientIp() + "_" + request.getTd() + "_" + request.getAppkey();
|
|
|
td=(arr[2] + "_" + arr[3]);
|
|
|
key = UNION_KEY + "_" + request.getClientIp() + "_" + td + "_" + request.getAppkey();
|
|
|
value = yhValueOperations.get(key);
|
|
|
log.info("activateUnion with get redis second with key={}, value={}", key, value);
|
|
|
clickUnion.info("activateUnion with get redis second with key={}, value={}", key, value);
|
|
|
activeUnion.info("activateUnion with get redis second with key={}, value={}", key, value);
|
|
|
}
|
|
|
if(arr.length==3){
|
|
|
request.setTd(arr[1]+"_"+arr[2]);
|
|
|
key = UNION_KEY + "_" + request.getClientIp() + "_" + request.getTd() + "_" + request.getAppkey();
|
|
|
value = yhValueOperations.get(key);
|
|
|
log.info("activateUnion with get redis third with key={}, value={}", key, value);
|
|
|
clickUnion.info("activateUnion with get redis third with key={}, value={}", key, value);
|
|
|
}
|
|
|
|
|
|
if(arr.length==3){
|
|
|
request.setTd(arr[1]+"_"+arr[2]);
|
|
|
key = UNION_KEY + "_" + request.getClientIp() + "_" + request.getTd() + "_" + request.getAppkey();
|
|
|
td = (arr[1]+"_"+arr[2]);
|
|
|
key = UNION_KEY + "_" + request.getClientIp() + "_" + td + "_" + request.getAppkey();
|
|
|
value = yhValueOperations.get(key);
|
|
|
log.info("activateUnion with get redis third with key={}, value={}", key, value);
|
|
|
activeUnion.info("activateUnion with get redis third with key={}, value={}", key, value);
|
|
|
}
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -323,10 +318,15 @@ public class UnionServiceImpl implements IUnionService { |
|
|
}else{
|
|
|
key = UNION_KEY + "_" + request.getClientIp() + "_" + request.getAppkey();
|
|
|
value = yhValueOperations.get(key);
|
|
|
if(StringUtils.isNotEmpty(value)){
|
|
|
ipMatch.info("activateUnion with IP params td is {},imei is {},idfa is {},IP is {},---- clickMsg is {}",request.getTd(),request.getImei(),request.getIdfa(),request.getClientIp(),value);
|
|
|
return new UnionResponse(204, "user not click");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
log.info("activateUnion with get redis forth with key={}, value={}", key, value);
|
|
|
clickUnion.info("activateUnion with get redis forth with key={}, value={}", key, value);
|
|
|
activeUnion.info("activateUnion with get redis forth with key={}, value={}", key, value);
|
|
|
}
|
|
|
|
|
|
// 如果redis中不存在存在该用户点击信息,则退出
|
...
|
...
|
@@ -395,6 +395,7 @@ public class UnionServiceImpl implements IUnionService { |
|
|
//15天内有记录,退出
|
|
|
log.warn("activateUnion error because 15 days has activate in bigdata database info with param is {}", request);
|
|
|
} else {
|
|
|
//根据mkt_markering
|
|
|
//15天内没有记录,则记录大数据日志,退出
|
|
|
JSONObject j = new JSONObject();
|
|
|
j.put("apptype", request.getClient_type());
|
...
|
...
|
|