Merge branch 'master' into hotfix_0307
Showing
8 changed files
with
146 additions
and
25 deletions
@@ -27,7 +27,6 @@ | @@ -27,7 +27,6 @@ | ||
27 | <value>/ActivateUnionRest/test</value> | 27 | <value>/ActivateUnionRest/test</value> |
28 | <value>/MobvistaUnionRest/addUnion4Mobvista</value> | 28 | <value>/MobvistaUnionRest/addUnion4Mobvista</value> |
29 | <value>/ActivateUnionRest/addActivate</value> | 29 | <value>/ActivateUnionRest/addActivate</value> |
30 | - <value>/ActivateUnionRest/addActivateLog</value> | ||
31 | <value>/ActivateUnionRest/queryActivateDeviceId</value> | 30 | <value>/ActivateUnionRest/queryActivateDeviceId</value> |
32 | <value>/UnionRest/addYas</value> | 31 | <value>/UnionRest/addYas</value> |
33 | <value>/ActivateUnionRest/queryActivateCount</value> | 32 | <value>/ActivateUnionRest/queryActivateCount</value> |
1 | package com.yoho.unions.dal.model; | 1 | package com.yoho.unions.dal.model; |
2 | 2 | ||
3 | import com.yoho.service.model.union.BaseBO; | 3 | import com.yoho.service.model.union.BaseBO; |
4 | +import org.apache.commons.lang.StringUtils; | ||
4 | 5 | ||
5 | public class AppActivateIdfaList extends BaseBO { | 6 | public class AppActivateIdfaList extends BaseBO { |
6 | /** | 7 | /** |
@@ -34,7 +35,9 @@ public class AppActivateIdfaList extends BaseBO { | @@ -34,7 +35,9 @@ public class AppActivateIdfaList extends BaseBO { | ||
34 | this.dateId = dateId; | 35 | this.dateId = dateId; |
35 | this.idfa = idfa; | 36 | this.idfa = idfa; |
36 | this.appKey = appKey; | 37 | this.appKey = appKey; |
37 | - this.udid = udid; | 38 | + if(StringUtils.isNotEmpty(udid)){ |
39 | + this.udid = udid; | ||
40 | + } | ||
38 | } | 41 | } |
39 | 42 | ||
40 | public String getUdid() { | 43 | public String getUdid() { |
@@ -11,6 +11,6 @@ | @@ -11,6 +11,6 @@ | ||
11 | </select> | 11 | </select> |
12 | 12 | ||
13 | <select id="select15DaysByIdfaAndDate" resultMap="BaseResultMap"> | 13 | <select id="select15DaysByIdfaAndDate" resultMap="BaseResultMap"> |
14 | - select * from app_activate_idfa_list_15days where date_id=#{dateId} and udid=#{udid} and app_key = #{appKey} | 14 | + select * from app_activate_idfa_list_15days where date_id=#{dateId} and idfa=#{idfa} and app_key = #{appKey} |
15 | </select> | 15 | </select> |
16 | </mapper> | 16 | </mapper> |
@@ -122,15 +122,23 @@ public class PinYouServiceImpl implements IPinYouService { | @@ -122,15 +122,23 @@ public class PinYouServiceImpl implements IPinYouService { | ||
122 | //客户端ip | 122 | //客户端ip |
123 | String ip = requestBO.getIp(); | 123 | String ip = requestBO.getIp(); |
124 | //debug flag | 124 | //debug flag |
125 | - String df = "0"; | ||
126 | //按照品友的格式进行拼接 | 125 | //按照品友的格式进行拼接 |
126 | + String df = "0"; | ||
127 | StringBuffer stringBuffer = new StringBuffer(); | 127 | StringBuffer stringBuffer = new StringBuffer(); |
128 | stringBuffer = stringBuffer.append(PINYOU_VIEW_URL).append("a=") | 128 | stringBuffer = stringBuffer.append(PINYOU_VIEW_URL).append("a=") |
129 | .append(advertiser).append("&os=").append(os) | 129 | .append(advertiser).append("&os=").append(os) |
130 | .append("&ts=").append(ts) | 130 | .append("&ts=").append(ts) |
131 | .append("&jp=1").append("&ip=").append(ip) | 131 | .append("&jp=1").append("&ip=").append(ip) |
132 | - .append("&event=").append(event) | ||
133 | - .append("&event_vaule=").append(event_value).append("&df=0"); | 132 | + .append("&event=").append(event); |
133 | + //由于搜索行为,event_value会有特殊字符,例如空格,所以需要URLEncode一下 | ||
134 | + if(event.equals(EnentValueEnum.VIEW_SEARCH.getName())){ | ||
135 | + try{ | ||
136 | + event_value = URLEncoder.encode(event_value,"UTF-8"); | ||
137 | + }catch (Exception e){ | ||
138 | + log.warn("URLEncode error message is {}",e.getMessage()); | ||
139 | + } | ||
140 | + } | ||
141 | + stringBuffer = stringBuffer.append("&event_vaule=").append(event_value).append("&df=0"); | ||
134 | String url = null; | 142 | String url = null; |
135 | if (event.equals(EnentValueEnum.ADD_CART.getName()) || event.equals(EnentValueEnum.VIEW_ITEM.getName())) { | 143 | if (event.equals(EnentValueEnum.ADD_CART.getName()) || event.equals(EnentValueEnum.VIEW_ITEM.getName())) { |
136 | stringBuffer = stringBuffer.append("&p=").append(event_value); | 144 | stringBuffer = stringBuffer.append("&p=").append(event_value); |
@@ -157,6 +165,7 @@ public class PinYouServiceImpl implements IPinYouService { | @@ -157,6 +165,7 @@ public class PinYouServiceImpl implements IPinYouService { | ||
157 | String advertiser = "MC.LF"; | 165 | String advertiser = "MC.LF"; |
158 | //操作系统信息 | 166 | //操作系统信息 |
159 | String os = requestBO.getOs(); | 167 | String os = requestBO.getOs(); |
168 | + String encode = null; | ||
160 | //根据从大数据获取的IDFA,IMEI来判断是安卓还是IOS | 169 | //根据从大数据获取的IDFA,IMEI来判断是安卓还是IOS |
161 | String client_type = ClientTypeEnum.IOS.getName(); | 170 | String client_type = ClientTypeEnum.IOS.getName(); |
162 | os = ClientTypeEnum.IOS.getName(); | 171 | os = ClientTypeEnum.IOS.getName(); |
@@ -204,9 +213,9 @@ public class PinYouServiceImpl implements IPinYouService { | @@ -204,9 +213,9 @@ public class PinYouServiceImpl implements IPinYouService { | ||
204 | stringBuffer = stringBuffer.append("&uid=").append(user_id); | 213 | stringBuffer = stringBuffer.append("&uid=").append(user_id); |
205 | } | 214 | } |
206 | if (orderStatus.equals("1") || orderStatus.equals("2")) { | 215 | if (orderStatus.equals("1") || orderStatus.equals("2")) { |
207 | - stringBuffer = stringBuffer.append("&gl=9466"); | 216 | + stringBuffer = stringBuffer.append("&gl=10593"); |
208 | } else { | 217 | } else { |
209 | - stringBuffer = stringBuffer.append("&gl=334"); | 218 | + stringBuffer = stringBuffer.append("&gl=10594"); |
210 | } | 219 | } |
211 | url = stringBuffer.toString(); | 220 | url = stringBuffer.toString(); |
212 | UnionResponse response = sendUrl(url); | 221 | UnionResponse response = sendUrl(url); |
@@ -216,13 +225,12 @@ public class PinYouServiceImpl implements IPinYouService { | @@ -216,13 +225,12 @@ public class PinYouServiceImpl implements IPinYouService { | ||
216 | public UnionResponse sendUrl(String url) { | 225 | public UnionResponse sendUrl(String url) { |
217 | log.info("pinyou sendUrl url is {}", url); | 226 | log.info("pinyou sendUrl url is {}", url); |
218 | try { | 227 | try { |
219 | - url = URLEncoder.encode(url, "UTF-8"); | ||
220 | Pair<Integer, String> pair = HttpUtils.httpGet(url); | 228 | Pair<Integer, String> pair = HttpUtils.httpGet(url); |
221 | log.info("pinyou sendUrl union success url={}, and result={}", url, pair); | 229 | log.info("pinyou sendUrl union success url={}, and result={}", url, pair); |
222 | if (pair.getLeft() != 200) { | 230 | if (pair.getLeft() != 200) { |
223 | log.warn("pinyou callback error with request={}", url); | 231 | log.warn("pinyou callback error with request={}", url); |
224 | - url = URLDecoder.decode(url,"UTF-8"); | ||
225 | - redisListCache.rightPushAll(UNION_SENDFAIL_KEY,url,6, TimeUnit.MINUTES); | 232 | +// url = URLDecoder.decode(url,"UTF-8"); |
233 | +// redisListCache.rightPushAll(UNION_SENDFAIL_KEY,url,4, TimeUnit.MINUTES); | ||
226 | return new UnionResponse(204, "callback error"); | 234 | return new UnionResponse(204, "callback error"); |
227 | } | 235 | } |
228 | } catch (Exception e) { | 236 | } catch (Exception e) { |
@@ -230,4 +238,6 @@ public class PinYouServiceImpl implements IPinYouService { | @@ -230,4 +238,6 @@ public class PinYouServiceImpl implements IPinYouService { | ||
230 | } | 238 | } |
231 | return new UnionResponse(); | 239 | return new UnionResponse(); |
232 | } | 240 | } |
241 | + | ||
242 | + | ||
233 | } | 243 | } |
@@ -210,7 +210,7 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher | @@ -210,7 +210,7 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher | ||
210 | clickUnion.info("clickUnion set redis with key={}, value={}", key, JSON.toJSONString(request)); | 210 | clickUnion.info("clickUnion set redis with key={}, value={}", key, JSON.toJSONString(request)); |
211 | yhValueOperations.set(key, JSON.toJSONString(request)); | 211 | yhValueOperations.set(key, JSON.toJSONString(request)); |
212 | String invalidTime = "activeTime"+"_"+request.getUnion_type(); | 212 | String invalidTime = "activeTime"+"_"+request.getUnion_type(); |
213 | - DynamicIntProperty activeTime = DynamicPropertyFactory.getInstance().getIntProperty(invalidTime, 3); | 213 | + DynamicIntProperty activeTime = DynamicPropertyFactory.getInstance().getIntProperty(invalidTime, 48); |
214 | yHRedisTemplate.longExpire(key, activeTime.get(), TimeUnit.HOURS); | 214 | yHRedisTemplate.longExpire(key, activeTime.get(), TimeUnit.HOURS); |
215 | 215 | ||
216 | 216 | ||
@@ -419,12 +419,39 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher | @@ -419,12 +419,39 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher | ||
419 | app_key = "yohomars_ios"; | 419 | app_key = "yohomars_ios"; |
420 | } | 420 | } |
421 | List<AppActivateIdfaList> _90DayIdfaList = appActivateIdfaListDAO.selectByUdidAndDate(new AppActivateIdfaList(Long.valueOf(yesterday), request.getUdid(), app_key)); | 421 | List<AppActivateIdfaList> _90DayIdfaList = appActivateIdfaListDAO.selectByUdidAndDate(new AppActivateIdfaList(Long.valueOf(yesterday), request.getUdid(), app_key)); |
422 | - 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); | ||
423 | -// List<AppActivateIdfaList> _15DayIdfaList = appActivateIdfaListDAO.select15DaysByIdfaAndDate(new AppActivateIdfaList(Long.valueOf(yesterday), request.getUdid(), app_key)); | 422 | + 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)); |
423 | + | ||
424 | + List<AppActivateIdfaList> _15DayIdfaList = appActivateIdfaListDAO.select15DaysByIdfaAndDate(new AppActivateIdfaList(Long.valueOf(yesterday), request.getIdfa(), app_key, null)); | ||
425 | + 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)); | ||
426 | + | ||
424 | //判断90天内是否在大数据有记录 | 427 | //判断90天内是否在大数据有记录 |
425 | if (CollectionUtils.isNotEmpty(_90DayIdfaList)) { | 428 | if (CollectionUtils.isNotEmpty(_90DayIdfaList)) { |
426 | log.warn("ios activateUnion error because 90 days has activate in bigdata database info with param is {}", request); | 429 | log.warn("ios activateUnion error because 90 days has activate in bigdata database info with param is {}", request); |
430 | + //判断15天内是否在大数据有记录 | ||
431 | + if (CollectionUtils.isNotEmpty(_15DayIdfaList)) { | ||
432 | + //15天内有记录,退出 | ||
433 | + log.warn("activateUnion error because 15 days has activate in bigdata database info with param is {}", request); | ||
434 | + } else { | ||
435 | + //根据mkt_markering | ||
436 | + //15天内没有记录,则记录大数据日志,退出 | ||
437 | + JSONObject j = new JSONObject(); | ||
438 | + j.put("apptype", request.getClient_type()); | ||
439 | + j.put("appid", click.getAppid()); | ||
440 | + j.put("idfa", request.getIdfa()); | ||
441 | + j.put("imei", request.getImei()); | ||
442 | + j.put("udid", request.getUdid()); | ||
443 | + j.put("dateid", DateUtil.getcurrentDateTime()); | ||
444 | + j.put("source", u == null ? "" : u.getName()); | ||
445 | + j.put("source_id",click.getUnion_type()); | ||
446 | + j.put("ip", request.getClientIp()); | ||
447 | + j.put("collect_ip", ""); | ||
448 | + j.put("app_key", request.getAppkey()); | ||
449 | + j.put("active_type", "15"); | ||
450 | + j.put("tdid", request.getTdid()); | ||
451 | + activeDingdang.info(j.toString()); | ||
452 | + } | ||
427 | return new UnionResponse(200, "have activite in 90 days",result); | 453 | return new UnionResponse(200, "have activite in 90 days",result); |
454 | + | ||
428 | } | 455 | } |
429 | } | 456 | } |
430 | 457 | ||
@@ -497,6 +524,10 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher | @@ -497,6 +524,10 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher | ||
497 | j.put("interfaceType",click.getInterfaceType()); | 524 | j.put("interfaceType",click.getInterfaceType()); |
498 | //打印90天的大数据日志 | 525 | //打印90天的大数据日志 |
499 | activeDingdang.info(j.toString()); | 526 | activeDingdang.info(j.toString()); |
527 | + //打印15天的日志 | ||
528 | + j.put("active_type", "15"); | ||
529 | + activeDingdang.info(j.toString()); | ||
530 | + | ||
500 | 531 | ||
501 | String source = u == null ? "" : u.getName(); | 532 | String source = u == null ? "" : u.getName(); |
502 | String source_id = click.getUnion_type(); | 533 | String source_id = click.getUnion_type(); |
@@ -59,11 +59,10 @@ public class PinYouTask { | @@ -59,11 +59,10 @@ public class PinYouTask { | ||
59 | //从redis里面获取大数据的数据 | 59 | //从redis里面获取大数据的数据 |
60 | Long viewSize = redisListCache.size(UNION_VIEW_KEY); | 60 | Long viewSize = redisListCache.size(UNION_VIEW_KEY); |
61 | Long transSize = redisListCache.size(UNION_TRANS_KEY); | 61 | Long transSize = redisListCache.size(UNION_TRANS_KEY); |
62 | - Long failSize = redisListCache.size(UNION_SENDFAIL_KEY); | ||
63 | List<ViewPinYouRequestBO> viewPinYouRequestBOList = new ArrayList<>(); | 62 | List<ViewPinYouRequestBO> viewPinYouRequestBOList = new ArrayList<>(); |
64 | int viewSizeInt = viewSize == null ? 0 : viewSize.intValue(); | 63 | int viewSizeInt = viewSize == null ? 0 : viewSize.intValue(); |
65 | int transSizeInt = transSize == null ? 0:transSize.intValue(); | 64 | int transSizeInt = transSize == null ? 0:transSize.intValue(); |
66 | - log.info("viewSize is {},transSize is {},failSize is {}",viewSizeInt,transSizeInt,failSize); | 65 | + log.info("viewSize is {},transSize is {}",viewSizeInt,transSizeInt); |
67 | List<TransPinYouRequestBO> transPinYouRequestBOList = new ArrayList<>(); | 66 | List<TransPinYouRequestBO> transPinYouRequestBOList = new ArrayList<>(); |
68 | if(transSizeInt>0){ | 67 | if(transSizeInt>0){ |
69 | for(int i=0; i < limit; i++){ | 68 | for(int i=0; i < limit; i++){ |
@@ -79,13 +78,6 @@ public class PinYouTask { | @@ -79,13 +78,6 @@ public class PinYouTask { | ||
79 | } | 78 | } |
80 | } | 79 | } |
81 | 80 | ||
82 | - if(failSize>0){ | ||
83 | - for(int i=0;i<failSize;i++){ | ||
84 | - String failUrl = redisListCache.rightPop(UNION_SENDFAIL_KEY,String.class); | ||
85 | - pinYouService.sendUrl(failUrl); | ||
86 | - } | ||
87 | - } | ||
88 | - | ||
89 | if(CollectionUtils.isNotEmpty(transPinYouRequestBOList)){ | 81 | if(CollectionUtils.isNotEmpty(transPinYouRequestBOList)){ |
90 | log.info("transPinYouRequestBOList size is {}",transPinYouRequestBOList.size()); | 82 | log.info("transPinYouRequestBOList size is {}",transPinYouRequestBOList.size()); |
91 | for(TransPinYouRequestBO transPinYouRequestBO:transPinYouRequestBOList){ | 83 | for(TransPinYouRequestBO transPinYouRequestBO:transPinYouRequestBOList){ |
@@ -47,9 +47,9 @@ web.context=union | @@ -47,9 +47,9 @@ web.context=union | ||
47 | draw.writeFile.delay=${draw.writeFile.delay} | 47 | draw.writeFile.delay=${draw.writeFile.delay} |
48 | 48 | ||
49 | #广点通 7*24 | 49 | #广点通 7*24 |
50 | -activeTime_3=24 | 50 | +activeTime_3=48 |
51 | #今日头条 24 | 51 | #今日头条 24 |
52 | -activeTime_4=24 | 52 | +activeTime_4=48 |
53 | #付费渠道 | 53 | #付费渠道 |
54 | activeTime_pay_channel=90 | 54 | activeTime_pay_channel=90 |
55 | 55 |
web/src/test/java/com/test/PinyouTest.java
0 → 100644
1 | +package com.test; | ||
2 | + | ||
3 | +import com.yoho.core.common.utils.MD5; | ||
4 | +import com.yoho.service.model.union.response.UnionResponse; | ||
5 | +import com.yoho.unions.common.enums.ClientTypeEnum; | ||
6 | +import com.yoho.unions.common.enums.EnentValueEnum; | ||
7 | +import com.yoho.unions.common.utils.DateUtil; | ||
8 | +import org.apache.commons.lang.StringUtils; | ||
9 | + | ||
10 | +import java.net.URLEncoder; | ||
11 | + | ||
12 | +/** | ||
13 | + * Created by dell on 2017/3/15. | ||
14 | + */ | ||
15 | +public class PinyouTest { | ||
16 | + | ||
17 | + public static void main (String args[]){ | ||
18 | + | ||
19 | + String PINYOU_VIEW_URL = "http://stats.ipinyou.com/madv?"; | ||
20 | + //广告主信息 | ||
21 | + String advertiser = "MC.LF"; | ||
22 | + //操作系统信息 | ||
23 | + String os = "android"; | ||
24 | + os = ClientTypeEnum.IOS.getName(); | ||
25 | + //根据从大数据获取的IDFA,IMEI来判断是安卓还是IOS | ||
26 | + String client_type = ClientTypeEnum.IOS.getName(); | ||
27 | + String idfa = ""; | ||
28 | + String imei = "87394281384"; | ||
29 | + if (idfa.equals("") || StringUtils.isEmpty(idfa)) { | ||
30 | + client_type = ClientTypeEnum.ANDROID.getName(); | ||
31 | + os = ClientTypeEnum.ANDROID.getName(); | ||
32 | + } | ||
33 | + //时间戳 | ||
34 | + String ts = "1489468089724"; | ||
35 | + if (StringUtils.isEmpty(ts)) { | ||
36 | + ts = String.valueOf(DateUtil.getCurrentTimeSecond() * 1000); | ||
37 | + } | ||
38 | + //启动参数,固定位1 | ||
39 | + String jp = "1"; | ||
40 | + //用户id | ||
41 | + String user_id = "123"; | ||
42 | + boolean isNum = user_id.matches("[0-9]+"); | ||
43 | + //用户行为事件 | ||
44 | + String event = "addCart"; | ||
45 | + //用户行为数据 | ||
46 | + String event_value = "三叶草女 卫衣"; | ||
47 | + //客户端ip | ||
48 | + String ip = "171.88.1.219"; | ||
49 | + //debug flag | ||
50 | + String df = "0"; | ||
51 | + //按照品友的格式进行拼接 | ||
52 | + StringBuffer stringBuffer = new StringBuffer(); | ||
53 | + stringBuffer = stringBuffer.append(PINYOU_VIEW_URL).append("a=") | ||
54 | + .append(advertiser).append("&os=").append(os) | ||
55 | + .append("&ts=").append(ts) | ||
56 | + .append("&jp=1").append("&ip=").append(ip) | ||
57 | + .append("&event=").append(event); | ||
58 | + //由于搜索行为,event_value会有特殊字符,例如空格,所以需要URLEncode一下 | ||
59 | + if(event.equals(EnentValueEnum.VIEW_SEARCH.getName())){ | ||
60 | + try{ | ||
61 | + event_value = URLEncoder.encode(event_value,"UTF-8"); | ||
62 | + }catch (Exception e){ | ||
63 | +// log.warn("URLEncode error message is {}",e.getMessage()); | ||
64 | + } | ||
65 | + } | ||
66 | + stringBuffer = stringBuffer.append("&event_vaule=").append(event_value).append("&df=0"); | ||
67 | + String url = null; | ||
68 | + if (event.equals(EnentValueEnum.ADD_CART.getName()) || event.equals(EnentValueEnum.VIEW_ITEM.getName())) { | ||
69 | + stringBuffer = stringBuffer.append("&p=").append(event_value); | ||
70 | + } | ||
71 | + if (StringUtils.isNotEmpty(user_id) && user_id.matches("[0-9]+")) { | ||
72 | + stringBuffer = stringBuffer.append("&uid=").append(user_id); | ||
73 | + } | ||
74 | + if (client_type.equalsIgnoreCase(ClientTypeEnum.ANDROID.getName())) { | ||
75 | + //如果是浏览商品和加入购物车则需要传p=商品编号 | ||
76 | + String dim = MD5.md5(imei); | ||
77 | + stringBuffer = stringBuffer.append("&dim=").append(dim); | ||
78 | + } | ||
79 | + if (client_type.equalsIgnoreCase(ClientTypeEnum.IOS.getName())) { | ||
80 | + String iam = MD5.md5(idfa); | ||
81 | + stringBuffer = stringBuffer.append("&iam=").append(iam); | ||
82 | + } | ||
83 | + url = stringBuffer.toString(); | ||
84 | + System.out.print(url); | ||
85 | + } | ||
86 | +} |
-
Please register or login to post a comment