|
|
/**
|
|
|
*
|
|
|
*/
|
|
|
package com.yoho.unions.server.restapi;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
import com.yoho.service.model.union.request.MobvistaRequestBO;
|
|
|
import com.yoho.unions.interceptor.RemoteIPInterceptor;
|
|
|
import com.yoho.unions.server.service.IMobvistaService;
|
|
|
|
|
|
/**
|
|
|
* 描述:统一的联盟入口
|
|
|
*
|
|
|
* @author caow
|
|
|
* 2016年7月25日
|
|
|
*/
|
|
|
@Controller
|
|
|
@RequestMapping("/ClickMobvistaUnionRest")
|
|
|
public class MobvistaUnionRest {
|
|
|
|
|
|
static Logger log = LoggerFactory.getLogger(MobvistaUnionRest.class);
|
|
|
|
|
|
static Logger clickUnion = LoggerFactory.getLogger("clickUnion");
|
|
|
@Resource
|
|
|
IMobvistaService mobvistaService;
|
|
|
|
|
|
/**
|
|
|
* 对Mobvista联盟进行特殊处理
|
|
|
* @param bo
|
|
|
* @param request
|
|
|
* @param response
|
|
|
*/
|
|
|
@RequestMapping("/addUnion4Mobvista")
|
|
|
public void addUnion4Mobvista(MobvistaRequestBO req, HttpServletRequest request, HttpServletResponse response) {
|
|
|
log.info("addUnion4Mobvista with param is {}", req);
|
|
|
clickUnion.info("addUnion4Mobvista with param is {}", req);
|
|
|
try {
|
|
|
String downloadURL="";
|
|
|
String agent = request.getHeader("user-agent");
|
|
|
log.info("user-agent={}", agent);
|
|
|
if (StringUtils.isEmpty(agent)) {
|
|
|
log.warn("addUnion4Mobvista user-agent is empty with req={}", req);
|
|
|
return;
|
|
|
}
|
|
|
//跳转到商店
|
|
|
if (agent.toLowerCase().indexOf("iphone") > -1 || agent.toLowerCase().indexOf("mac os x") > -1) {
|
|
|
//IOS
|
|
|
req.setDevice_type("ios");
|
|
|
downloadURL = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8";
|
|
|
}else if(agent.toLowerCase().indexOf("android") > -1 || agent.toLowerCase().indexOf("linux") > -1){
|
|
|
//Android
|
|
|
req.setDevice_type("android");
|
|
|
downloadURL = "http://cdn.yoho.cn/app-downfiles/yohoBuy_YOHO_2953.apk";
|
|
|
}
|
|
|
req.setIp(RemoteIPInterceptor.getRemoteIP());
|
|
|
String url = "http://stat.mobvista.com/install?mobvista_pl="+req.getDevice_type()+"&mobvista_campuuid="+req.getUuid()+""
|
|
|
+ "&mobvista_ip="+req.getIp()+"&mobvista_clickid="+req.getClickid()+"&mobvista_gaid=&mobvista_devid=";
|
|
|
req.setCallbackurl(url);
|
|
|
mobvistaService.recordUserClickAdLink(req);
|
|
|
response.setStatus(302);
|
|
|
response.sendRedirect(downloadURL);
|
|
|
} catch (IOException e) {
|
|
|
log.error("addUnion4Mobvista error with request={}", req, e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|