Authored by zhengwen.ge

Merge branch 'master' into hotfix_0307

... ... @@ -27,7 +27,6 @@
<value>/ActivateUnionRest/test</value>
<value>/MobvistaUnionRest/addUnion4Mobvista</value>
<value>/ActivateUnionRest/addActivate</value>
<value>/ActivateUnionRest/addActivateLog</value>
<value>/ActivateUnionRest/queryActivateDeviceId</value>
<value>/UnionRest/addYas</value>
<value>/ActivateUnionRest/queryActivateCount</value>
... ...
package com.yoho.unions.dal.model;
import com.yoho.service.model.union.BaseBO;
import org.apache.commons.lang.StringUtils;
public class AppActivateIdfaList extends BaseBO {
/**
... ... @@ -34,7 +35,9 @@ public class AppActivateIdfaList extends BaseBO {
this.dateId = dateId;
this.idfa = idfa;
this.appKey = appKey;
this.udid = udid;
if(StringUtils.isNotEmpty(udid)){
this.udid = udid;
}
}
public String getUdid() {
... ...
... ... @@ -11,6 +11,6 @@
</select>
<select id="select15DaysByIdfaAndDate" resultMap="BaseResultMap">
select * from app_activate_idfa_list_15days where date_id=#{dateId} and udid=#{udid} and app_key = #{appKey}
select * from app_activate_idfa_list_15days where date_id=#{dateId} and idfa=#{idfa} and app_key = #{appKey}
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -122,15 +122,23 @@ public class PinYouServiceImpl implements IPinYouService {
//客户端ip
String ip = requestBO.getIp();
//debug flag
String df = "0";
//按照品友的格式进行拼接
String df = "0";
StringBuffer stringBuffer = new StringBuffer();
stringBuffer = stringBuffer.append(PINYOU_VIEW_URL).append("a=")
.append(advertiser).append("&os=").append(os)
.append("&ts=").append(ts)
.append("&jp=1").append("&ip=").append(ip)
.append("&event=").append(event)
.append("&event_vaule=").append(event_value).append("&df=0");
.append("&event=").append(event);
//由于搜索行为,event_value会有特殊字符,例如空格,所以需要URLEncode一下
if(event.equals(EnentValueEnum.VIEW_SEARCH.getName())){
try{
event_value = URLEncoder.encode(event_value,"UTF-8");
}catch (Exception e){
log.warn("URLEncode error message is {}",e.getMessage());
}
}
stringBuffer = stringBuffer.append("&event_vaule=").append(event_value).append("&df=0");
String url = null;
if (event.equals(EnentValueEnum.ADD_CART.getName()) || event.equals(EnentValueEnum.VIEW_ITEM.getName())) {
stringBuffer = stringBuffer.append("&p=").append(event_value);
... ... @@ -157,6 +165,7 @@ public class PinYouServiceImpl implements IPinYouService {
String advertiser = "MC.LF";
//操作系统信息
String os = requestBO.getOs();
String encode = null;
//根据从大数据获取的IDFA,IMEI来判断是安卓还是IOS
String client_type = ClientTypeEnum.IOS.getName();
os = ClientTypeEnum.IOS.getName();
... ... @@ -204,9 +213,9 @@ public class PinYouServiceImpl implements IPinYouService {
stringBuffer = stringBuffer.append("&uid=").append(user_id);
}
if (orderStatus.equals("1") || orderStatus.equals("2")) {
stringBuffer = stringBuffer.append("&gl=9466");
stringBuffer = stringBuffer.append("&gl=10593");
} else {
stringBuffer = stringBuffer.append("&gl=334");
stringBuffer = stringBuffer.append("&gl=10594");
}
url = stringBuffer.toString();
UnionResponse response = sendUrl(url);
... ... @@ -216,13 +225,12 @@ public class PinYouServiceImpl implements IPinYouService {
public UnionResponse sendUrl(String url) {
log.info("pinyou sendUrl url is {}", url);
try {
url = URLEncoder.encode(url, "UTF-8");
Pair<Integer, String> pair = HttpUtils.httpGet(url);
log.info("pinyou sendUrl union success url={}, and result={}", url, pair);
if (pair.getLeft() != 200) {
log.warn("pinyou callback error with request={}", url);
url = URLDecoder.decode(url,"UTF-8");
redisListCache.rightPushAll(UNION_SENDFAIL_KEY,url,6, TimeUnit.MINUTES);
// url = URLDecoder.decode(url,"UTF-8");
// redisListCache.rightPushAll(UNION_SENDFAIL_KEY,url,4, TimeUnit.MINUTES);
return new UnionResponse(204, "callback error");
}
} catch (Exception e) {
... ... @@ -230,4 +238,6 @@ public class PinYouServiceImpl implements IPinYouService {
}
return new UnionResponse();
}
}
... ...
... ... @@ -210,7 +210,7 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
clickUnion.info("clickUnion set redis with key={}, value={}", key, JSON.toJSONString(request));
yhValueOperations.set(key, JSON.toJSONString(request));
String invalidTime = "activeTime"+"_"+request.getUnion_type();
DynamicIntProperty activeTime = DynamicPropertyFactory.getInstance().getIntProperty(invalidTime, 3);
DynamicIntProperty activeTime = DynamicPropertyFactory.getInstance().getIntProperty(invalidTime, 48);
yHRedisTemplate.longExpire(key, activeTime.get(), TimeUnit.HOURS);
... ... @@ -419,12 +419,39 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
app_key = "yohomars_ios";
}
List<AppActivateIdfaList> _90DayIdfaList = appActivateIdfaListDAO.selectByUdidAndDate(new AppActivateIdfaList(Long.valueOf(yesterday), request.getUdid(), app_key));
activeUnion.info("check ios active info in 90 days. udid is {} and app_key is {},yesterday is {} and result is {}", request.getUdid(), app_key, yesterday, _90DayIdfaList);
// List<AppActivateIdfaList> _15DayIdfaList = appActivateIdfaListDAO.select15DaysByIdfaAndDate(new AppActivateIdfaList(Long.valueOf(yesterday), request.getUdid(), app_key));
activeUnion.info("check ios active info in 90 days. udid is {} and app_key is {},yesterday is {} and result is {}", request.getUdid(), app_key, yesterday, (_90DayIdfaList.isEmpty())? "null": _90DayIdfaList.get(0));
List<AppActivateIdfaList> _15DayIdfaList = appActivateIdfaListDAO.select15DaysByIdfaAndDate(new AppActivateIdfaList(Long.valueOf(yesterday), request.getIdfa(), app_key, null));
activeUnion.info("check ios active info in 15 days. udid is {} and app_key is {},yesterday is {} and result is {}", request.getUdid(), app_key, yesterday, (_90DayIdfaList.isEmpty())? "null": _15DayIdfaList.get(0));
//判断90天内是否在大数据有记录
if (CollectionUtils.isNotEmpty(_90DayIdfaList)) {
log.warn("ios activateUnion error because 90 days has activate in bigdata database info with param is {}", request);
//判断15天内是否在大数据有记录
if (CollectionUtils.isNotEmpty(_15DayIdfaList)) {
//15天内有记录,退出
log.warn("activateUnion error because 15 days has activate in bigdata database info with param is {}", request);
} else {
//根据mkt_markering
//15天内没有记录,则记录大数据日志,退出
JSONObject j = new JSONObject();
j.put("apptype", request.getClient_type());
j.put("appid", click.getAppid());
j.put("idfa", request.getIdfa());
j.put("imei", request.getImei());
j.put("udid", request.getUdid());
j.put("dateid", DateUtil.getcurrentDateTime());
j.put("source", u == null ? "" : u.getName());
j.put("source_id",click.getUnion_type());
j.put("ip", request.getClientIp());
j.put("collect_ip", "");
j.put("app_key", request.getAppkey());
j.put("active_type", "15");
j.put("tdid", request.getTdid());
activeDingdang.info(j.toString());
}
return new UnionResponse(200, "have activite in 90 days",result);
}
}
... ... @@ -497,6 +524,10 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
j.put("interfaceType",click.getInterfaceType());
//打印90天的大数据日志
activeDingdang.info(j.toString());
//打印15天的日志
j.put("active_type", "15");
activeDingdang.info(j.toString());
String source = u == null ? "" : u.getName();
String source_id = click.getUnion_type();
... ...
... ... @@ -59,11 +59,10 @@ public class PinYouTask {
//从redis里面获取大数据的数据
Long viewSize = redisListCache.size(UNION_VIEW_KEY);
Long transSize = redisListCache.size(UNION_TRANS_KEY);
Long failSize = redisListCache.size(UNION_SENDFAIL_KEY);
List<ViewPinYouRequestBO> viewPinYouRequestBOList = new ArrayList<>();
int viewSizeInt = viewSize == null ? 0 : viewSize.intValue();
int transSizeInt = transSize == null ? 0:transSize.intValue();
log.info("viewSize is {},transSize is {},failSize is {}",viewSizeInt,transSizeInt,failSize);
log.info("viewSize is {},transSize is {}",viewSizeInt,transSizeInt);
List<TransPinYouRequestBO> transPinYouRequestBOList = new ArrayList<>();
if(transSizeInt>0){
for(int i=0; i < limit; i++){
... ... @@ -79,13 +78,6 @@ public class PinYouTask {
}
}
if(failSize>0){
for(int i=0;i<failSize;i++){
String failUrl = redisListCache.rightPop(UNION_SENDFAIL_KEY,String.class);
pinYouService.sendUrl(failUrl);
}
}
if(CollectionUtils.isNotEmpty(transPinYouRequestBOList)){
log.info("transPinYouRequestBOList size is {}",transPinYouRequestBOList.size());
for(TransPinYouRequestBO transPinYouRequestBO:transPinYouRequestBOList){
... ...
... ... @@ -47,9 +47,9 @@ web.context=union
draw.writeFile.delay=${draw.writeFile.delay}
#广点通 7*24
activeTime_3=24
activeTime_3=48
#今日头条 24
activeTime_4=24
activeTime_4=48
#付费渠道
activeTime_pay_channel=90
... ...
package com.test;
import com.yoho.core.common.utils.MD5;
import com.yoho.service.model.union.response.UnionResponse;
import com.yoho.unions.common.enums.ClientTypeEnum;
import com.yoho.unions.common.enums.EnentValueEnum;
import com.yoho.unions.common.utils.DateUtil;
import org.apache.commons.lang.StringUtils;
import java.net.URLEncoder;
/**
* Created by dell on 2017/3/15.
*/
public class PinyouTest {
public static void main (String args[]){
String PINYOU_VIEW_URL = "http://stats.ipinyou.com/madv?";
//广告主信息
String advertiser = "MC.LF";
//操作系统信息
String os = "android";
os = ClientTypeEnum.IOS.getName();
//根据从大数据获取的IDFA,IMEI来判断是安卓还是IOS
String client_type = ClientTypeEnum.IOS.getName();
String idfa = "";
String imei = "87394281384";
if (idfa.equals("") || StringUtils.isEmpty(idfa)) {
client_type = ClientTypeEnum.ANDROID.getName();
os = ClientTypeEnum.ANDROID.getName();
}
//时间戳
String ts = "1489468089724";
if (StringUtils.isEmpty(ts)) {
ts = String.valueOf(DateUtil.getCurrentTimeSecond() * 1000);
}
//启动参数,固定位1
String jp = "1";
//用户id
String user_id = "123";
boolean isNum = user_id.matches("[0-9]+");
//用户行为事件
String event = "addCart";
//用户行为数据
String event_value = "三叶草女 卫衣";
//客户端ip
String ip = "171.88.1.219";
//debug flag
String df = "0";
//按照品友的格式进行拼接
StringBuffer stringBuffer = new StringBuffer();
stringBuffer = stringBuffer.append(PINYOU_VIEW_URL).append("a=")
.append(advertiser).append("&os=").append(os)
.append("&ts=").append(ts)
.append("&jp=1").append("&ip=").append(ip)
.append("&event=").append(event);
//由于搜索行为,event_value会有特殊字符,例如空格,所以需要URLEncode一下
if(event.equals(EnentValueEnum.VIEW_SEARCH.getName())){
try{
event_value = URLEncoder.encode(event_value,"UTF-8");
}catch (Exception e){
// log.warn("URLEncode error message is {}",e.getMessage());
}
}
stringBuffer = stringBuffer.append("&event_vaule=").append(event_value).append("&df=0");
String url = null;
if (event.equals(EnentValueEnum.ADD_CART.getName()) || event.equals(EnentValueEnum.VIEW_ITEM.getName())) {
stringBuffer = stringBuffer.append("&p=").append(event_value);
}
if (StringUtils.isNotEmpty(user_id) && user_id.matches("[0-9]+")) {
stringBuffer = stringBuffer.append("&uid=").append(user_id);
}
if (client_type.equalsIgnoreCase(ClientTypeEnum.ANDROID.getName())) {
//如果是浏览商品和加入购物车则需要传p=商品编号
String dim = MD5.md5(imei);
stringBuffer = stringBuffer.append("&dim=").append(dim);
}
if (client_type.equalsIgnoreCase(ClientTypeEnum.IOS.getName())) {
String iam = MD5.md5(idfa);
stringBuffer = stringBuffer.append("&iam=").append(iam);
}
url = stringBuffer.toString();
System.out.print(url);
}
}
... ...