Authored by zhengwen.ge

Merge branch 'dev-20170216'

@@ -27,6 +27,8 @@ public class MktMarketingUrl { @@ -27,6 +27,8 @@ public class MktMarketingUrl {
27 27
28 private String mktActivityCode; 28 private String mktActivityCode;
29 29
  30 + private String landingPageUrl;
  31 +
30 public String getMktActivityCode() { 32 public String getMktActivityCode() {
31 return mktActivityCode; 33 return mktActivityCode;
32 } 34 }
@@ -130,4 +132,12 @@ public class MktMarketingUrl { @@ -130,4 +132,12 @@ public class MktMarketingUrl {
130 public void setCreateTime(Integer createTime) { 132 public void setCreateTime(Integer createTime) {
131 this.createTime = createTime; 133 this.createTime = createTime;
132 } 134 }
  135 +
  136 + public String getLandingPageUrl() {
  137 + return landingPageUrl;
  138 + }
  139 +
  140 + public void setLandingPageUrl(String landingPageUrl) {
  141 + this.landingPageUrl = landingPageUrl;
  142 + }
133 } 143 }
@@ -15,10 +15,11 @@ @@ -15,10 +15,11 @@
15 <result column="status" property="status" jdbcType="INTEGER" /> 15 <result column="status" property="status" jdbcType="INTEGER" />
16 <result column="create_time" property="createTime" jdbcType="INTEGER" /> 16 <result column="create_time" property="createTime" jdbcType="INTEGER" />
17 <result column="mkt_activity_code" property="mktActivityCode" jdbcType="VARCHAR" /> 17 <result column="mkt_activity_code" property="mktActivityCode" jdbcType="VARCHAR" />
  18 + <result column="landing_page_url" property="landingPageUrl" jdbcType="VARCHAR" />
18 </resultMap> 19 </resultMap>
19 <sql id="Base_Column_List" > 20 <sql id="Base_Column_List" >
20 union_type, division_code, class_code, channel_code, device_code, dept_id, create_id, 21 union_type, division_code, class_code, channel_code, device_code, dept_id, create_id,
21 - name, src_url, dest_url, status, create_time,mkt_activity_code 22 + name, src_url, dest_url, status, create_time,mkt_activity_code,landing_page_url
22 </sql> 23 </sql>
23 <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" > 24 <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
24 select 25 select
@@ -62,7 +62,7 @@ public class ActivateUnionRest { @@ -62,7 +62,7 @@ public class ActivateUnionRest {
62 * @return 62 * @return
63 */ 63 */
64 @RequestMapping("/activateUnion") 64 @RequestMapping("/activateUnion")
65 - @ResponseBody public ActiveUnionResponseBO activateUnion(ActivateUnionRequestVO vo, HttpServletRequest request, HttpServletResponse response) { 65 + @ResponseBody public UnionResponse activateUnion(ActivateUnionRequestVO vo, HttpServletRequest request, HttpServletResponse response) {
66 log.info("activateUnion with param is {}", vo); 66 log.info("activateUnion with param is {}", vo);
67 if ("iphone".equals(vo.getClient_type())) { 67 if ("iphone".equals(vo.getClient_type())) {
68 vo.setClient_type(ClientTypeEnum.IOS.getName()); 68 vo.setClient_type(ClientTypeEnum.IOS.getName());
@@ -97,7 +97,7 @@ public class ActivateUnionRest { @@ -97,7 +97,7 @@ public class ActivateUnionRest {
97 97
98 if (!ClientTypeEnum.ANDROID.getName().equalsIgnoreCase(clientType) && !ClientTypeEnum.IOS.getName().equalsIgnoreCase(clientType)) { 98 if (!ClientTypeEnum.ANDROID.getName().equalsIgnoreCase(clientType) && !ClientTypeEnum.IOS.getName().equalsIgnoreCase(clientType)) {
99 log.warn("activateUnion error with param is {}", vo); 99 log.warn("activateUnion error with param is {}", vo);
100 - return new ActiveUnionResponseBO(600, "error"); 100 + return new UnionResponse(200, "error",new JSONObject());
101 } 101 }
102 //IP取出来的有可能是42.239.40.36,123.151.42.50,只取第一个 102 //IP取出来的有可能是42.239.40.36,123.151.42.50,只取第一个
103 String IP = RemoteIPInterceptor.getRemoteIP(); 103 String IP = RemoteIPInterceptor.getRemoteIP();
@@ -108,8 +108,40 @@ public class ActivateUnionRest { @@ -108,8 +108,40 @@ public class ActivateUnionRest {
108 } 108 }
109 bo.setClientIp(clientIp); 109 bo.setClientIp(clientIp);
110 //多线程处理 110 //多线程处理
111 - exe.execute(new RunActivate(bo));  
112 - return new ActiveUnionResponseBO(200, "success"); 111 + //exe.execute(new RunActivate(bo));
  112 + return getGoUrl(bo);
  113 + }
  114 +
  115 + private UnionResponse getGoUrl(ActivateUnionRequestBO bo){
  116 + MainUnionService service = null;
  117 + if (ClientTypeEnum.ANDROID.getName().equalsIgnoreCase(bo.getClient_type())) {
  118 + //处理安卓的服务
  119 + for (String str : UnionConstant.andriodServiceList) {
  120 + //捕获异常,不影响后面的联盟
  121 + try {
  122 + service = SpringContextUtil.getBean(str, MainUnionService.class);
  123 + service.activeUnion(bo);
  124 + } catch (Exception e) {
  125 + log.warn("addUnion error with param is {}", bo, e);
  126 + }
  127 + }
  128 + } else if (ClientTypeEnum.IOS.getName().equalsIgnoreCase(bo.getClient_type())) {
  129 + //处理iOS的服务
  130 + for (String str : UnionConstant.iOSServiceList) {
  131 + //捕获异常,不影响后面的联盟
  132 + try {
  133 + service = SpringContextUtil.getBean(str, MainUnionService.class);
  134 + service.activeUnion(bo);
  135 + } catch (Exception e) {
  136 + log.warn("addUnion error with param is {}", bo, e);
  137 + }
  138 + }
  139 + }
  140 +
  141 + //调用统一的联盟激活接口
  142 + IUnionService unionService = SpringContextUtil.getBean("unionServiceImpl", IUnionService.class);
  143 + activeUnion.info("activeUnion request is {}",bo);
  144 + return unionService.activateUnion(bo);
113 } 145 }
114 146
115 public static class RunActivate implements Runnable { 147 public static class RunActivate implements Runnable {
@@ -122,35 +154,7 @@ public class ActivateUnionRest { @@ -122,35 +154,7 @@ public class ActivateUnionRest {
122 154
123 @Override 155 @Override
124 public void run() { 156 public void run() {
125 - MainUnionService service = null;  
126 - if (ClientTypeEnum.ANDROID.getName().equalsIgnoreCase(bo.getClient_type())) {  
127 - //处理安卓的服务  
128 - for (String str : UnionConstant.andriodServiceList) {  
129 - //捕获异常,不影响后面的联盟  
130 - try {  
131 - service = SpringContextUtil.getBean(str, MainUnionService.class);  
132 - service.activeUnion(bo);  
133 - } catch (Exception e) {  
134 - log.warn("addUnion error with param is {}", bo, e);  
135 - }  
136 - }  
137 - } else if (ClientTypeEnum.IOS.getName().equalsIgnoreCase(bo.getClient_type())) {  
138 - //处理iOS的服务  
139 - for (String str : UnionConstant.iOSServiceList) {  
140 - //捕获异常,不影响后面的联盟  
141 - try {  
142 - service = SpringContextUtil.getBean(str, MainUnionService.class);  
143 - service.activeUnion(bo);  
144 - } catch (Exception e) {  
145 - log.warn("addUnion error with param is {}", bo, e);  
146 - }  
147 - }  
148 - }  
149 157
150 - //调用统一的联盟激活接口  
151 - IUnionService unionService = SpringContextUtil.getBean("unionServiceImpl", IUnionService.class);  
152 - activeUnion.info("activeUnion request is {}",bo);  
153 - unionService.activateUnion(bo);  
154 158
155 } 159 }
156 public ActivateUnionRequestBO getBo() { 160 public ActivateUnionRequestBO getBo() {
@@ -217,25 +217,25 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher @@ -217,25 +217,25 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
217 // 检查输入参数 217 // 检查输入参数
218 if (StringUtils.isEmpty(request.getAppid())) { 218 if (StringUtils.isEmpty(request.getAppid())) {
219 log.warn("activateUnion error because appid is empty with param is {}", request); 219 log.warn("activateUnion error because appid is empty with param is {}", request);
220 - return new UnionResponse(201, "appid is empty"); 220 + return new UnionResponse(200, "appid is empty",new JSONObject());
221 } 221 }
222 if (StringUtils.isEmpty(request.getTd())) { 222 if (StringUtils.isEmpty(request.getTd())) {
223 log.warn("activateUnion error because td is empty with param is {}", request); 223 log.warn("activateUnion error because td is empty with param is {}", request);
224 - return new UnionResponse(201, "td is empty"); 224 + return new UnionResponse(200, "td is empty",new JSONObject());
225 } 225 }
226 if (StringUtils.isEmpty(request.getUdid())) { 226 if (StringUtils.isEmpty(request.getUdid())) {
227 log.warn("activateUnion error because udid is empty with param is {}", request); 227 log.warn("activateUnion error because udid is empty with param is {}", request);
228 - return new UnionResponse(201, "udid is empty"); 228 + return new UnionResponse(200, "udid is empty",new JSONObject());
229 } 229 }
230 230
231 if (ClientTypeEnum.IOS.getName().equals(request.getClient_type()) && StringUtils.isEmpty(request.getIdfa())) { 231 if (ClientTypeEnum.IOS.getName().equals(request.getClient_type()) && StringUtils.isEmpty(request.getIdfa())) {
232 log.warn("activateUnion error because idfa is empty with request is {}", request); 232 log.warn("activateUnion error because idfa is empty with request is {}", request);
233 - return new UnionResponse(201, "idfa is empty"); 233 + return new UnionResponse(200, "idfa is empty",new JSONObject());
234 } 234 }
235 235
236 if (ClientTypeEnum.ANDROID.getName().equals(request.getClient_type()) && StringUtils.isEmpty(request.getImei())) { 236 if (ClientTypeEnum.ANDROID.getName().equals(request.getClient_type()) && StringUtils.isEmpty(request.getImei())) {
237 log.warn("activateUnion error because imei is empty with request is {}", request); 237 log.warn("activateUnion error because imei is empty with request is {}", request);
238 - return new UnionResponse(201, "imei is empty"); 238 + return new UnionResponse(200, "imei is empty",new JSONObject());
239 } 239 }
240 240
241 try{ 241 try{
@@ -316,7 +316,7 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher @@ -316,7 +316,7 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
316 value = yhValueOperations.get(key); 316 value = yhValueOperations.get(key);
317 if(StringUtils.isNotEmpty(value)){ 317 if(StringUtils.isNotEmpty(value)){
318 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); 318 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);
319 - return new UnionResponse(204, "user not click"); 319 + return new UnionResponse(200, "user not click",new JSONObject());
320 } 320 }
321 321
322 } 322 }
@@ -327,7 +327,7 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher @@ -327,7 +327,7 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
327 // 如果redis中不存在存在该用户点击信息,则退出 327 // 如果redis中不存在存在该用户点击信息,则退出
328 if (StringUtils.isEmpty(value)) { 328 if (StringUtils.isEmpty(value)) {
329 log.warn("activateUnion error user not click info. with param is {}", request); 329 log.warn("activateUnion error user not click info. with param is {}", request);
330 - return new UnionResponse(204, "user not click"); 330 + return new UnionResponse(200, "user not click",new JSONObject());
331 } 331 }
332 332
333 // 把存储的字符串变为对象 333 // 把存储的字符串变为对象
@@ -349,17 +349,23 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher @@ -349,17 +349,23 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
349 //强制删除带ip的key 349 //强制删除带ip的key
350 yHRedisTemplate.delete(UNION_KEY + "_" + request.getClientIp() + "_" + request.getAppkey()); 350 yHRedisTemplate.delete(UNION_KEY + "_" + request.getClientIp() + "_" + request.getAppkey());
351 351
352 - if (union != null && union.getIsActivate() != null && union.getIsActivate().byteValue() == 1) {  
353 - // 如果90天之内有过激活日志,则不允许重复激活  
354 - log.warn("activateUnion error because 90 days has activate info with param is {}", request);  
355 - return new UnionResponse(203, "have activite in 90 days");  
356 - }  
357 String unionTypekey = "yh:union:uniontype:"+click.getUnion_type(); 352 String unionTypekey = "yh:union:uniontype:"+click.getUnion_type();
358 MktMarketingUrl mktMarketingUrl = redisValueCache.get(unionTypekey,MktMarketingUrl.class); 353 MktMarketingUrl mktMarketingUrl = redisValueCache.get(unionTypekey,MktMarketingUrl.class);
359 if(mktMarketingUrl==null){ 354 if(mktMarketingUrl==null){
360 mktMarketingUrl = mktMarketingUrlDAO.selectByPrimaryKey(Long.valueOf(click.getUnion_type())); 355 mktMarketingUrl = mktMarketingUrlDAO.selectByPrimaryKey(Long.valueOf(click.getUnion_type()));
361 redisValueCache.set(unionTypekey, mktMarketingUrl, 1, TimeUnit.HOURS); 356 redisValueCache.set(unionTypekey, mktMarketingUrl, 1, TimeUnit.HOURS);
362 } 357 }
  358 +
  359 + JSONObject result = new JSONObject();
  360 + result.put("landing_page_url",StringUtils.isEmpty(mktMarketingUrl.getLandingPageUrl()) ? "" : mktMarketingUrl.getLandingPageUrl());
  361 +
  362 + if (union != null && union.getIsActivate() != null && union.getIsActivate().byteValue() == 1) {
  363 + // 如果90天之内有过激活日志,则不允许重复激活
  364 + log.warn("activateUnion error because 90 days has activate info with param is {}", request);
  365 + return new UnionResponse(200, "have activite in 90 days",result);
  366 + }
  367 +// UnionTypeModel u = UnionConstant.unionTypeMap.get(Integer.parseInt(click.getUnion_type()));
  368 +
363 UnionTypeModel u = new UnionTypeModel(); 369 UnionTypeModel u = new UnionTypeModel();
364 u.setName(mktMarketingUrl.getName()); 370 u.setName(mktMarketingUrl.getName());
365 u.setValue(String.valueOf(mktMarketingUrl.getUnionType())); 371 u.setValue(String.valueOf(mktMarketingUrl.getUnionType()));
@@ -407,7 +413,7 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher @@ -407,7 +413,7 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
407 j.put("tdid", request.getTdid()); 413 j.put("tdid", request.getTdid());
408 activeDingdang.info(j.toString()); 414 activeDingdang.info(j.toString());
409 } 415 }
410 - return new UnionResponse(203, "have activite in 90 days"); 416 + return new UnionResponse(200, "have activite in 90 days",result);
411 } 417 }
412 } 418 }
413 419
@@ -489,7 +495,7 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher @@ -489,7 +495,7 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
489 } 495 }
490 if (StringUtils.isEmpty(url)) { 496 if (StringUtils.isEmpty(url)) {
491 log.info("activateUnion in success request is {}", request); 497 log.info("activateUnion in success request is {}", request);
492 - return new UnionResponse(); 498 + return new UnionResponse(200,"success",result);
493 } 499 }
494 if(!"3".equals(union_type)||!"100000000000453".equals(union_type)){ 500 if(!"3".equals(union_type)||!"100000000000453".equals(union_type)){
495 url = URLDecoder.decode(url, "UTF-8"); 501 url = URLDecoder.decode(url, "UTF-8");
@@ -506,7 +512,7 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher @@ -506,7 +512,7 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
506 activeUnion.info("activateUnion call union success url={}, and result={}", url, pair); 512 activeUnion.info("activateUnion call union success url={}, and result={}", url, pair);
507 if (pair.getLeft() != 200) { 513 if (pair.getLeft() != 200) {
508 log.warn("callback error with request={}", request); 514 log.warn("callback error with request={}", request);
509 - return new UnionResponse(204, "callback error"); 515 + return new UnionResponse(200, "callback error",result);
510 } 516 }
511 //如果来源是广点通,则把广点通的一些信息记入表,给之后做转化上报使用 517 //如果来源是广点通,则把广点通的一些信息记入表,给之后做转化上报使用
512 if(union_type.equals("3")){ 518 if(union_type.equals("3")){
@@ -520,12 +526,12 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher @@ -520,12 +526,12 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
520 } 526 }
521 527
522 activeUnion.info("activateUnion in success request is {}", request); 528 activeUnion.info("activateUnion in success request is {}", request);
523 -  
524 - return new UnionResponse(); 529 +
  530 + return new UnionResponse(200,"success",result);
525 531
526 } catch (Exception e) { 532 } catch (Exception e) {
527 log.error("activateUnion error with request={}", request, e); 533 log.error("activateUnion error with request={}", request, e);
528 - return new UnionResponse(300, e.getMessage()); 534 + return new UnionResponse(200, e.getMessage(),new JSONObject());
529 } 535 }
530 536
531 } 537 }