...
|
...
|
@@ -3,6 +3,7 @@ |
|
|
*/
|
|
|
package com.yoho.unions.server.service.impl;
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.netflix.config.DynamicIntProperty;
|
...
|
...
|
@@ -30,7 +31,6 @@ import org.apache.commons.lang3.tuple.Pair; |
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.net.URLDecoder;
|
|
|
import java.util.List;
|
...
|
...
|
@@ -127,12 +127,14 @@ public class UnionServiceImpl implements IUnionService { |
|
|
log.warn("clickUnion error because union_type is error with param is {}", request);
|
|
|
return new UnionResponse(201, "union_type is error");
|
|
|
}
|
|
|
|
|
|
//异步记录日志表,以后查询日志方便
|
|
|
try {
|
|
|
saveLog(request);
|
|
|
} catch (Exception e) {
|
|
|
log.error("", e);
|
|
|
}
|
|
|
|
|
|
//组装redis保存的key
|
|
|
String key;
|
|
|
if (StringUtils.isNotEmpty(request.getIdfa())) {
|
...
|
...
|
@@ -207,27 +209,7 @@ public class UnionServiceImpl implements IUnionService { |
|
|
return new UnionResponse(300, e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//异步记录点击日志表
|
|
|
private void saveLog(ClickUnionRequestBO request){
|
|
|
taskExecutor.execute(new Runnable() {
|
|
|
@Override
|
|
|
public void run()
|
|
|
{
|
|
|
UnionClickLogs unionClickLogs = new UnionClickLogs();
|
|
|
unionClickLogs.setUnionType(request.getUnion_type());
|
|
|
unionClickLogs.setTd(request.getTd());
|
|
|
unionClickLogs.setIdfa(request.getIdfa());
|
|
|
unionClickLogs.setImei(request.getImei());
|
|
|
unionClickLogs.setClientIp(request.getClientIp());
|
|
|
unionClickLogs.setAppKey(request.getAppkey());
|
|
|
unionClickLogs.setAppId(request.getAppid());
|
|
|
unionClickLogs.setCreateTime(DateUtil.getCurrentTimeSecond());
|
|
|
unionClickLogsDAO.insertSelective(unionClickLogs);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public UnionResponse activateUnion(ActivateUnionRequestBO request) throws ServiceException {
|
|
|
try {
|
...
|
...
|
@@ -257,6 +239,11 @@ public class UnionServiceImpl implements IUnionService { |
|
|
}
|
|
|
|
|
|
saveActivityLog(request);
|
|
|
try{
|
|
|
saveActivityLog(request);
|
|
|
}catch (Exception e){
|
|
|
log.error("activity save log error is {}",e.getMessage());
|
|
|
}
|
|
|
|
|
|
// 组装redis保存的key
|
|
|
String key = "";
|
...
|
...
|
@@ -332,8 +319,13 @@ public class UnionServiceImpl implements IUnionService { |
|
|
}
|
|
|
|
|
|
if (StringUtils.isEmpty(value)) {
|
|
|
key = UNION_KEY + "_" + request.getClientIp() + "_" + request.getAppkey();
|
|
|
value = yhValueOperations.get(key);
|
|
|
if(StringUtils.isEmpty(request.getClientIp())){
|
|
|
value = null;
|
|
|
}else{
|
|
|
key = UNION_KEY + "_" + request.getClientIp() + "_" + request.getAppkey();
|
|
|
value = yhValueOperations.get(key);
|
|
|
}
|
|
|
|
|
|
log.info("activateUnion with get redis forth with key={}, value={}", key, value);
|
|
|
clickUnion.info("activateUnion with get redis forth with key={}, value={}", key, value);
|
|
|
}
|
...
|
...
|
@@ -532,6 +524,27 @@ public class UnionServiceImpl implements IUnionService { |
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
//异步记录点击日志表
|
|
|
private void saveLog(ClickUnionRequestBO request){
|
|
|
taskExecutor.execute(new Runnable() {
|
|
|
@Override
|
|
|
public void run()
|
|
|
{
|
|
|
UnionClickLogs unionClickLogs = new UnionClickLogs();
|
|
|
unionClickLogs.setUnionType(request.getUnion_type());
|
|
|
unionClickLogs.setTd(request.getTd());
|
|
|
unionClickLogs.setIdfa(request.getIdfa());
|
|
|
unionClickLogs.setImei(request.getImei());
|
|
|
unionClickLogs.setClientIp(request.getClientIp());
|
|
|
unionClickLogs.setAppKey(request.getAppkey());
|
|
|
unionClickLogs.setAppId(request.getAppid());
|
|
|
unionClickLogs.setCreateTime(DateUtil.getCurrentTimeSecond());
|
|
|
unionClickLogsDAO.insertSelective(unionClickLogs);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
private void saveActivityLog(ActivateUnionRequestBO request){
|
|
|
taskExecutor.execute(new Runnable() {
|
|
|
@Override
|
...
|
...
|
|