Authored by zhengwen.ge

Merge branch 'dev-20170216'

... ... @@ -27,6 +27,8 @@ public class MktMarketingUrl {
private String mktActivityCode;
private String landingPageUrl;
public String getMktActivityCode() {
return mktActivityCode;
}
... ... @@ -130,4 +132,12 @@ public class MktMarketingUrl {
public void setCreateTime(Integer createTime) {
this.createTime = createTime;
}
public String getLandingPageUrl() {
return landingPageUrl;
}
public void setLandingPageUrl(String landingPageUrl) {
this.landingPageUrl = landingPageUrl;
}
}
\ No newline at end of file
... ...
... ... @@ -15,10 +15,11 @@
<result column="status" property="status" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="mkt_activity_code" property="mktActivityCode" jdbcType="VARCHAR" />
<result column="landing_page_url" property="landingPageUrl" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
union_type, division_code, class_code, channel_code, device_code, dept_id, create_id,
name, src_url, dest_url, status, create_time,mkt_activity_code
name, src_url, dest_url, status, create_time,mkt_activity_code,landing_page_url
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
select
... ...
... ... @@ -62,7 +62,7 @@ public class ActivateUnionRest {
* @return
*/
@RequestMapping("/activateUnion")
@ResponseBody public ActiveUnionResponseBO activateUnion(ActivateUnionRequestVO vo, HttpServletRequest request, HttpServletResponse response) {
@ResponseBody public UnionResponse activateUnion(ActivateUnionRequestVO vo, HttpServletRequest request, HttpServletResponse response) {
log.info("activateUnion with param is {}", vo);
if ("iphone".equals(vo.getClient_type())) {
vo.setClient_type(ClientTypeEnum.IOS.getName());
... ... @@ -97,7 +97,7 @@ public class ActivateUnionRest {
if (!ClientTypeEnum.ANDROID.getName().equalsIgnoreCase(clientType) && !ClientTypeEnum.IOS.getName().equalsIgnoreCase(clientType)) {
log.warn("activateUnion error with param is {}", vo);
return new ActiveUnionResponseBO(600, "error");
return new UnionResponse(200, "error",new JSONObject());
}
//IP取出来的有可能是42.239.40.36,123.151.42.50,只取第一个
String IP = RemoteIPInterceptor.getRemoteIP();
... ... @@ -108,8 +108,40 @@ public class ActivateUnionRest {
}
bo.setClientIp(clientIp);
//多线程处理
exe.execute(new RunActivate(bo));
return new ActiveUnionResponseBO(200, "success");
//exe.execute(new RunActivate(bo));
return getGoUrl(bo);
}
private UnionResponse getGoUrl(ActivateUnionRequestBO bo){
MainUnionService service = null;
if (ClientTypeEnum.ANDROID.getName().equalsIgnoreCase(bo.getClient_type())) {
//处理安卓的服务
for (String str : UnionConstant.andriodServiceList) {
//捕获异常,不影响后面的联盟
try {
service = SpringContextUtil.getBean(str, MainUnionService.class);
service.activeUnion(bo);
} catch (Exception e) {
log.warn("addUnion error with param is {}", bo, e);
}
}
} else if (ClientTypeEnum.IOS.getName().equalsIgnoreCase(bo.getClient_type())) {
//处理iOS的服务
for (String str : UnionConstant.iOSServiceList) {
//捕获异常,不影响后面的联盟
try {
service = SpringContextUtil.getBean(str, MainUnionService.class);
service.activeUnion(bo);
} catch (Exception e) {
log.warn("addUnion error with param is {}", bo, e);
}
}
}
//调用统一的联盟激活接口
IUnionService unionService = SpringContextUtil.getBean("unionServiceImpl", IUnionService.class);
activeUnion.info("activeUnion request is {}",bo);
return unionService.activateUnion(bo);
}
public static class RunActivate implements Runnable {
... ... @@ -122,35 +154,7 @@ public class ActivateUnionRest {
@Override
public void run() {
MainUnionService service = null;
if (ClientTypeEnum.ANDROID.getName().equalsIgnoreCase(bo.getClient_type())) {
//处理安卓的服务
for (String str : UnionConstant.andriodServiceList) {
//捕获异常,不影响后面的联盟
try {
service = SpringContextUtil.getBean(str, MainUnionService.class);
service.activeUnion(bo);
} catch (Exception e) {
log.warn("addUnion error with param is {}", bo, e);
}
}
} else if (ClientTypeEnum.IOS.getName().equalsIgnoreCase(bo.getClient_type())) {
//处理iOS的服务
for (String str : UnionConstant.iOSServiceList) {
//捕获异常,不影响后面的联盟
try {
service = SpringContextUtil.getBean(str, MainUnionService.class);
service.activeUnion(bo);
} catch (Exception e) {
log.warn("addUnion error with param is {}", bo, e);
}
}
}
//调用统一的联盟激活接口
IUnionService unionService = SpringContextUtil.getBean("unionServiceImpl", IUnionService.class);
activeUnion.info("activeUnion request is {}",bo);
unionService.activateUnion(bo);
}
public ActivateUnionRequestBO getBo() {
... ...
... ... @@ -217,25 +217,25 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
// 检查输入参数
if (StringUtils.isEmpty(request.getAppid())) {
log.warn("activateUnion error because appid is empty with param is {}", request);
return new UnionResponse(201, "appid is empty");
return new UnionResponse(200, "appid is empty",new JSONObject());
}
if (StringUtils.isEmpty(request.getTd())) {
log.warn("activateUnion error because td is empty with param is {}", request);
return new UnionResponse(201, "td is empty");
return new UnionResponse(200, "td is empty",new JSONObject());
}
if (StringUtils.isEmpty(request.getUdid())) {
log.warn("activateUnion error because udid is empty with param is {}", request);
return new UnionResponse(201, "udid is empty");
return new UnionResponse(200, "udid is empty",new JSONObject());
}
if (ClientTypeEnum.IOS.getName().equals(request.getClient_type()) && StringUtils.isEmpty(request.getIdfa())) {
log.warn("activateUnion error because idfa is empty with request is {}", request);
return new UnionResponse(201, "idfa is empty");
return new UnionResponse(200, "idfa is empty",new JSONObject());
}
if (ClientTypeEnum.ANDROID.getName().equals(request.getClient_type()) && StringUtils.isEmpty(request.getImei())) {
log.warn("activateUnion error because imei is empty with request is {}", request);
return new UnionResponse(201, "imei is empty");
return new UnionResponse(200, "imei is empty",new JSONObject());
}
try{
... ... @@ -316,7 +316,7 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
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");
return new UnionResponse(200, "user not click",new JSONObject());
}
}
... ... @@ -327,7 +327,7 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
// 如果redis中不存在存在该用户点击信息,则退出
if (StringUtils.isEmpty(value)) {
log.warn("activateUnion error user not click info. with param is {}", request);
return new UnionResponse(204, "user not click");
return new UnionResponse(200, "user not click",new JSONObject());
}
// 把存储的字符串变为对象
... ... @@ -349,17 +349,23 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
//强制删除带ip的key
yHRedisTemplate.delete(UNION_KEY + "_" + request.getClientIp() + "_" + request.getAppkey());
if (union != null && union.getIsActivate() != null && union.getIsActivate().byteValue() == 1) {
// 如果90天之内有过激活日志,则不允许重复激活
log.warn("activateUnion error because 90 days has activate info with param is {}", request);
return new UnionResponse(203, "have activite in 90 days");
}
String unionTypekey = "yh:union:uniontype:"+click.getUnion_type();
MktMarketingUrl mktMarketingUrl = redisValueCache.get(unionTypekey,MktMarketingUrl.class);
if(mktMarketingUrl==null){
mktMarketingUrl = mktMarketingUrlDAO.selectByPrimaryKey(Long.valueOf(click.getUnion_type()));
redisValueCache.set(unionTypekey, mktMarketingUrl, 1, TimeUnit.HOURS);
}
JSONObject result = new JSONObject();
result.put("landing_page_url",StringUtils.isEmpty(mktMarketingUrl.getLandingPageUrl()) ? "" : mktMarketingUrl.getLandingPageUrl());
if (union != null && union.getIsActivate() != null && union.getIsActivate().byteValue() == 1) {
// 如果90天之内有过激活日志,则不允许重复激活
log.warn("activateUnion error because 90 days has activate info with param is {}", request);
return new UnionResponse(200, "have activite in 90 days",result);
}
// UnionTypeModel u = UnionConstant.unionTypeMap.get(Integer.parseInt(click.getUnion_type()));
UnionTypeModel u = new UnionTypeModel();
u.setName(mktMarketingUrl.getName());
u.setValue(String.valueOf(mktMarketingUrl.getUnionType()));
... ... @@ -407,7 +413,7 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
j.put("tdid", request.getTdid());
activeDingdang.info(j.toString());
}
return new UnionResponse(203, "have activite in 90 days");
return new UnionResponse(200, "have activite in 90 days",result);
}
}
... ... @@ -489,7 +495,7 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
}
if (StringUtils.isEmpty(url)) {
log.info("activateUnion in success request is {}", request);
return new UnionResponse();
return new UnionResponse(200,"success",result);
}
if(!"3".equals(union_type)||!"100000000000453".equals(union_type)){
url = URLDecoder.decode(url, "UTF-8");
... ... @@ -506,7 +512,7 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
activeUnion.info("activateUnion call union success url={}, and result={}", url, pair);
if (pair.getLeft() != 200) {
log.warn("callback error with request={}", request);
return new UnionResponse(204, "callback error");
return new UnionResponse(200, "callback error",result);
}
//如果来源是广点通,则把广点通的一些信息记入表,给之后做转化上报使用
if(union_type.equals("3")){
... ... @@ -520,12 +526,12 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
}
activeUnion.info("activateUnion in success request is {}", request);
return new UnionResponse();
return new UnionResponse(200,"success",result);
} catch (Exception e) {
log.error("activateUnion error with request={}", request, e);
return new UnionResponse(300, e.getMessage());
return new UnionResponse(200, e.getMessage(),new JSONObject());
}
}
... ...