Authored by zhouxiang

首次激活打开落地页

... ... @@ -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(600, "error");
}
//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);
}
@RequestMapping("/test")
... ... @@ -128,35 +160,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() {
... ...
... ... @@ -359,18 +359,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");
}
// UnionTypeModel u = UnionConstant.unionTypeMap.get(Integer.parseInt(click.getUnion_type()));
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",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(203, "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()));
... ... @@ -418,7 +423,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(203, "have activite in 90 days",result);
}
}
... ... @@ -501,7 +506,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)){
url = URLDecoder.decode(url, "UTF-8");
... ... @@ -530,7 +535,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(204, "callback error",result);
}
} catch (Exception e) {
log.error("callback error with request={}", request, e);
... ... @@ -539,8 +544,8 @@ 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);
... ...