Authored by zhengwen.ge

update

... ... @@ -11,6 +11,9 @@ union_types:
- value: 4
name: test
- value: 5
name: weibo
- value: 100
name: ASZM-fensitong
... ...
... ... @@ -97,7 +97,7 @@ public class ClickUnionRest {
request = unionService.clickHttpRequestTOBO(httpServletRequest);
}
bo.setClientIp(RemoteIPInterceptor.getRemoteIP());
request.setClientIp(RemoteIPInterceptor.getRemoteIP());
// IUnionService service = SpringContextUtil.getBean(bean, IUnionService.class);
UnionResponse response = unionService.clickUnion(request);
log.info("addUnion with result is {}, and request is {}", response, request);
... ... @@ -130,14 +130,14 @@ public class ClickUnionRest {
log.warn("addUnion4Special agent is not correct with user-agent={}, bo={}", agent, bo);
return;
}
String version = agent.substring(agent.indexOf(" OS ") + 4, agent.indexOf(" like"));
log.info("addUnion4Special version={}", version);
bo.setTd("ios_" + version.replaceAll("_", "."));
bo.setClient_type("ios");
bo.setAppid("490655927");
log.info("addUnion4Special request={}", bo);
unionService.clickUnion(request);
unionService.clickUnion(bo);
log.info("addUnion4Special with result is {}, and request is {}", response, bo);
response.setStatus(301);
response.sendRedirect("https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8");
... ... @@ -158,19 +158,19 @@ public class ClickUnionRest {
String version = agent.substring(agent.indexOf(" OS ") + 4, agent.indexOf(" like"));
log.info("addUnion4Special version={}", version);
}
@RequestMapping("/addMonitor")
public void addMonitor(ClickUnionRequestBO bo, HttpServletRequest request, HttpServletResponse response) {
log.info("addMonitor with param is {}", bo);
clickUnion.info("addMonitor with param is {}", bo);
try {
Enumeration<String> e = request.getParameterNames();
while (e.hasMoreElements()) {
String key = e.nextElement();
log.info("addMonitor with key={}, value={}", key, request.getParameter(key));
}
bo.setClientIp(RemoteIPInterceptor.getRemoteIP());
String agent = request.getHeader("user-agent");
log.info("addMonitor user-agent={}", agent);
... ... @@ -183,7 +183,7 @@ public class ClickUnionRest {
bo.setClient_type("ios");
bo.setAppid("490655927");
log.info("addMonitor request={}", bo);
unionService.clickUnion(request);
unionService.clickUnion(bo);
log.info("addMonitor with result is {}, and request is {}", response, bo);
response.setStatus(200);
} catch (Exception e) {
... ...
... ... @@ -7,6 +7,7 @@ import com.yoho.service.model.union.request.ClickUnionRequestBO;
import com.yoho.unions.common.enums.ClientTypeEnum;
import com.yoho.unions.server.service.IUnionService;
import com.yoho.unions.server.service.IUniteService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
... ... @@ -24,11 +25,19 @@ public class TouTiaoServiceImpl implements IUniteService {
ClickUnionRequestBO bo = new ClickUnionRequestBO();
String idfa = request.getParameter("idfa");
String imei = request.getParameter("imei");
bo.setIdfa(idfa.replaceAll("__",""));
bo.setImei(imei.replaceAll("__",""));
if(StringUtils.isNotEmpty(idfa)){
bo.setIdfa(idfa.replaceAll("__",""));
}
if(StringUtils.isNotEmpty(imei)){
bo.setImei(imei.replaceAll("__",""));
}
//将毫秒级的转换为秒级别
bo.setClickTime(Integer.valueOf(request.getParameter("timestamp"))/1000);
bo.setTd(request.getParameter("td"));
bo.setUnion_type(request.getParameter("union_type"));
bo.setAppid(request.getParameter("appid"));
String callBackUrl = request.getParameter("callback_url");
bo.setCallbackurl(callBackUrl.replaceAll("__",""));
return bo;
... ...
... ... @@ -73,6 +73,9 @@ public class UnionServiceImpl implements IUnionService {
@Resource
IAppActivateIdfaListDAO appActivateIdfaListDAO;
@Resource(name="unionServiceImpl")
IUnionService unionService;
@Override
public UnionResponse clickUnion(ClickUnionRequestBO request) throws ServiceException {
... ... @@ -336,18 +339,19 @@ public class UnionServiceImpl implements IUnionService {
// UnionTypeModel type =
// UnionConstant.unionTypeMap.get(Integer.parseInt(click.getUnion_type()));
String url = click.getCallbackurl();
String url = null;
//取出具体是哪个union_type
//根据不同的url走不同的回调
try {
if(StringUtils.isEmpty(url)){
String union_type = click.getUnion_type();
StringBuffer buffer = new StringBuffer();
String bean =buffer.append("UnionServiceImpl").append("_").append(union_type).toString();
String union_type = click.getUnion_type();
StringBuffer buffer = new StringBuffer();
String bean =buffer.append("UnionServiceImpl").append("_").append(union_type).toString();
if(SpringContextUtil.containsBean(bean)){
IUniteService uniteService = SpringContextUtil.getBean(bean, IUniteService.class);
url = uniteService.getCallbackUrl(click,request);
}else{
url = unionService.getCallbackUrl(click,request);
}
if (StringUtils.isEmpty(url)) {
log.info("activateUnion in success request is {}", request);
return new UnionResponse();
... ...
... ... @@ -23,10 +23,12 @@ public class WeiBoServiceImpl implements IUniteService {
clickUnionRequestBO.setIdfa(request.getParameter("idfa_md5"));
clickUnionRequestBO.setClientIp(request.getParameter("ip"));
//微博是毫秒,将其转换成秒
(Long.valueOf(request.getParameter("clicktime")))/1000;
clickUnionRequestBO.setClickTime(Integer.valueOf(Long.valueOf(request.getParameter("clicktime"))));
Long clicktime = Long.valueOf(request.getParameter("clicktime"));
clickUnionRequestBO.setClickTime((int)(clicktime/1000));
clickUnionRequestBO.setCallbackurl(request.getParameter("IMP"));
clickUnionRequestBO.setTd(request.getParameter("td"));
clickUnionRequestBO.setAppid(request.getParameter("appid"));
clickUnionRequestBO.setUnion_type(request.getParameter("union_type"));
return clickUnionRequestBO;
}
... ... @@ -38,7 +40,7 @@ public class WeiBoServiceImpl implements IUniteService {
String weiboUrl = "http://appmonitor.biz.weibo.com/sdkserver/active?company=";
String adv = "yoho";
StringBuffer sb = new StringBuffer();
String url = sb.append(weiboUrl).append(adv).append(imp).toString();
String url = sb.append(weiboUrl).append(adv).append("&IMP").append(imp).toString();
return url;
}
... ...