Merge branch 'master' of git.yoho.cn:yoho30/yohobuy-union
Showing
9 changed files
with
165 additions
and
40 deletions
@@ -39,5 +39,5 @@ public interface IUnionLogsDAO { | @@ -39,5 +39,5 @@ public interface IUnionLogsDAO { | ||
39 | 39 | ||
40 | List<UnionLogs> queryByDeviceId(ActivateDeviceIdReqBO activateDeviceIdReqBO); | 40 | List<UnionLogs> queryByDeviceId(ActivateDeviceIdReqBO activateDeviceIdReqBO); |
41 | 41 | ||
42 | - List<ActivateDeviceIdRspBO> selectListByHour(ActivateDeviceIdReqBO activateDeviceIdReqBO); | 42 | + List<UnionLogs> selectListByHour(ActivateDeviceIdReqBO activateDeviceIdReqBO); |
43 | } | 43 | } |
@@ -188,9 +188,9 @@ | @@ -188,9 +188,9 @@ | ||
188 | </if> | 188 | </if> |
189 | limit 1 | 189 | limit 1 |
190 | </select> | 190 | </select> |
191 | - <select id="selectListByHour" resultMap="ActivateMap" | 191 | + <select id="selectListByHour" resultMap="BaseResultMap" |
192 | parameterType="com.yoho.service.model.union.request.ActivateDeviceIdReqBO"> | 192 | parameterType="com.yoho.service.model.union.request.ActivateDeviceIdReqBO"> |
193 | - select union_type,union_name,count(idfa) as idfa_count,count(imei) as imei_count | 193 | + select <include refid="Base_Column_List"/> |
194 | from union_logs | 194 | from union_logs |
195 | where union_type = #{unionType} | 195 | where union_type = #{unionType} |
196 | <if test="activateHourBegin != null and activateHourBegin>0"> | 196 | <if test="activateHourBegin != null and activateHourBegin>0"> |
@@ -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,24, TimeUnit.HOURS); | 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 | } |
@@ -7,6 +7,7 @@ package com.yoho.unions.server.service.impl; | @@ -7,6 +7,7 @@ package com.yoho.unions.server.service.impl; | ||
7 | import com.alibaba.fastjson.JSON; | 7 | import com.alibaba.fastjson.JSON; |
8 | import com.alibaba.fastjson.JSONObject; | 8 | import com.alibaba.fastjson.JSONObject; |
9 | import com.google.common.collect.Lists; | 9 | import com.google.common.collect.Lists; |
10 | +import com.google.common.collect.Maps; | ||
10 | import com.netflix.config.DynamicIntProperty; | 11 | import com.netflix.config.DynamicIntProperty; |
11 | import com.netflix.config.DynamicPropertyFactory; | 12 | import com.netflix.config.DynamicPropertyFactory; |
12 | import com.yoho.core.common.utils.MD5; | 13 | import com.yoho.core.common.utils.MD5; |
@@ -48,6 +49,7 @@ import javax.annotation.Resource; | @@ -48,6 +49,7 @@ import javax.annotation.Resource; | ||
48 | import java.net.URLDecoder; | 49 | import java.net.URLDecoder; |
49 | import java.util.ArrayList; | 50 | import java.util.ArrayList; |
50 | import java.util.List; | 51 | import java.util.List; |
52 | +import java.util.Map; | ||
51 | import java.util.concurrent.ExecutorService; | 53 | import java.util.concurrent.ExecutorService; |
52 | import java.util.concurrent.LinkedBlockingQueue; | 54 | import java.util.concurrent.LinkedBlockingQueue; |
53 | import java.util.concurrent.ThreadPoolExecutor; | 55 | import java.util.concurrent.ThreadPoolExecutor; |
@@ -205,7 +207,7 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher | @@ -205,7 +207,7 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher | ||
205 | clickUnion.info("clickUnion set redis with key={}, value={}", key, JSON.toJSONString(request)); | 207 | clickUnion.info("clickUnion set redis with key={}, value={}", key, JSON.toJSONString(request)); |
206 | yhValueOperations.set(key, JSON.toJSONString(request)); | 208 | yhValueOperations.set(key, JSON.toJSONString(request)); |
207 | String invalidTime = "activeTime"+"_"+request.getUnion_type(); | 209 | String invalidTime = "activeTime"+"_"+request.getUnion_type(); |
208 | - DynamicIntProperty activeTime = DynamicPropertyFactory.getInstance().getIntProperty(invalidTime, 3); | 210 | + DynamicIntProperty activeTime = DynamicPropertyFactory.getInstance().getIntProperty(invalidTime, 48); |
209 | yHRedisTemplate.longExpire(key, activeTime.get(), TimeUnit.HOURS); | 211 | yHRedisTemplate.longExpire(key, activeTime.get(), TimeUnit.HOURS); |
210 | 212 | ||
211 | 213 | ||
@@ -830,29 +832,51 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher | @@ -830,29 +832,51 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher | ||
830 | public PageActivateDeviceIdRspBO queryActivateHour(ActivateDeviceIdReqBO activateDeviceIdReqBO) { | 832 | public PageActivateDeviceIdRspBO queryActivateHour(ActivateDeviceIdReqBO activateDeviceIdReqBO) { |
831 | log.info("enter queryActivateHour. param activateDeviceIdReqBO={}", activateDeviceIdReqBO); | 833 | log.info("enter queryActivateHour. param activateDeviceIdReqBO={}", activateDeviceIdReqBO); |
832 | 834 | ||
833 | - //(1).查询出各渠道激活的设备id数 | ||
834 | - List<ActivateDeviceIdRspBO> activateDeviceIdRspList = Lists.newArrayList(); | ||
835 | - | ||
836 | - int beginTime = DateUtils.getTodayZero(); | 835 | + //1.初始化map,用于存放24个小时的激活idfa和imei |
836 | + Map<Integer,List<Integer>> countMap = Maps.newHashMap(); | ||
837 | for(int i=0;i<24;i++){ | 837 | for(int i=0;i<24;i++){ |
838 | - activateDeviceIdReqBO.setActivateHourBegin(beginTime); | ||
839 | - activateDeviceIdReqBO.setActivateHourEnd(beginTime+3600); | ||
840 | - activateDeviceIdRspList.addAll(unionLogsDAO.selectListByHour(activateDeviceIdReqBO)); | ||
841 | - beginTime +=3600; | 838 | + List<Integer> countList = Lists.newArrayList(); |
839 | + countList.add(0); | ||
840 | + countList.add(0); | ||
841 | + countMap.put(i,countList); | ||
842 | } | 842 | } |
843 | 843 | ||
844 | - | 844 | + String searchDay = DateUtils.int2DateStr(activateDeviceIdReqBO.getActivateTimeEnd(),"yyyy/MM/dd"); |
845 | + int beginTime = DateUtils.getTimesmorning(searchDay); | ||
846 | + int endTime = beginTime+3600*24-1; | ||
847 | + activateDeviceIdReqBO.setActivateHourBegin(beginTime); | ||
848 | + activateDeviceIdReqBO.setActivateHourEnd(endTime); | ||
849 | + //2.查询出一个渠道一天的激活数 | ||
850 | + List<UnionLogs> unionLogs = unionLogsDAO.selectListByHour(activateDeviceIdReqBO); | ||
851 | + | ||
852 | + for(int i=0;i<unionLogs.size();i++){ | ||
853 | + UnionLogs unionLog = unionLogs.get(i); | ||
854 | + String createTime = DateUtils.int2DateStr(unionLog.getCreateTime(),"yyyy-MM-dd HH:mm:ss"); | ||
855 | + //3.遍历一天的记录,统计每小时的激活数 | ||
856 | + int key = Integer.parseInt(createTime.substring(11,13)); | ||
857 | + List<Integer> countList = countMap.get(key); | ||
858 | + //list第一个元素是idfa的激活数 | ||
859 | + if(StringUtils.isNotEmpty(unionLog.getIdfa())){ | ||
860 | + countList.set(0,countList.get(0)+1); | ||
861 | + } | ||
862 | + //list第二个元素是idfa的激活数 | ||
863 | + if (StringUtils.isNotEmpty(unionLog.getImei())){ | ||
864 | + countList.set(1,countList.get(1)+1); | ||
865 | + } | ||
866 | + } | ||
867 | + List<ActivateDeviceIdRspBO> activateDeviceIdRspList = Lists.newArrayList(); | ||
845 | for(int i=0;i<24;i++){ | 868 | for(int i=0;i<24;i++){ |
846 | - ActivateDeviceIdRspBO bo = activateDeviceIdRspList.get(i); | 869 | + ActivateDeviceIdRspBO bo = new ActivateDeviceIdRspBO(); |
847 | String hour = i<10?"0"+i+":00--"+"0"+i+":59":i+":00--"+i+":59"; | 870 | String hour = i<10?"0"+i+":00--"+"0"+i+":59":i+":00--"+i+":59"; |
848 | bo.setHour(hour); | 871 | bo.setHour(hour); |
872 | + List<Integer> countList = countMap.get(i); | ||
873 | + bo.setIdfaCount(countList.get(0)); | ||
874 | + bo.setImeiCount(countList.get(1)); | ||
875 | + activateDeviceIdRspList.add(bo); | ||
849 | } | 876 | } |
850 | 877 | ||
851 | PageActivateDeviceIdRspBO pageActivateDeviceIdRspBO = new PageActivateDeviceIdRspBO(); | 878 | PageActivateDeviceIdRspBO pageActivateDeviceIdRspBO = new PageActivateDeviceIdRspBO(); |
852 | pageActivateDeviceIdRspBO.setList(activateDeviceIdRspList); | 879 | pageActivateDeviceIdRspBO.setList(activateDeviceIdRspList); |
853 | - //不需要分页了 | ||
854 | -// pageActivateDeviceIdRspBO.setTotal(total); | ||
855 | -// pageActivateDeviceIdRspBO.setPage(activateDeviceIdReqBO.getPage()); | ||
856 | return pageActivateDeviceIdRspBO; | 880 | return pageActivateDeviceIdRspBO; |
857 | } | 881 | } |
858 | 882 |
@@ -59,7 +59,6 @@ public class PinYouTask { | @@ -59,7 +59,6 @@ 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(); |
@@ -68,7 +67,6 @@ public class PinYouTask { | @@ -68,7 +67,6 @@ public class PinYouTask { | ||
68 | if(transSizeInt>0){ | 67 | if(transSizeInt>0){ |
69 | for(int i=0; i < limit; i++){ | 68 | for(int i=0; i < limit; i++){ |
70 | TransPinYouRequestBO transPinYouRequestBO = redisListCache.rightPop(UNION_TRANS_KEY, TransPinYouRequestBO.class); | 69 | TransPinYouRequestBO transPinYouRequestBO = redisListCache.rightPop(UNION_TRANS_KEY, TransPinYouRequestBO.class); |
71 | - log.info("transPinYouRequestBO is {}",transPinYouRequestBO); | ||
72 | transPinYouRequestBOList.add(transPinYouRequestBO); | 70 | transPinYouRequestBOList.add(transPinYouRequestBO); |
73 | } | 71 | } |
74 | } | 72 | } |
@@ -80,13 +78,6 @@ public class PinYouTask { | @@ -80,13 +78,6 @@ public class PinYouTask { | ||
80 | } | 78 | } |
81 | } | 79 | } |
82 | 80 | ||
83 | - if(failSize>0){ | ||
84 | - for(int i=0;i<failSize;i++){ | ||
85 | - String failUrl = redisListCache.rightPop(UNION_SENDFAIL_KEY,String.class); | ||
86 | - pinYouService.sendUrl(failUrl); | ||
87 | - } | ||
88 | - } | ||
89 | - | ||
90 | if(CollectionUtils.isNotEmpty(transPinYouRequestBOList)){ | 81 | if(CollectionUtils.isNotEmpty(transPinYouRequestBOList)){ |
91 | log.info("transPinYouRequestBOList size is {}",transPinYouRequestBOList.size()); | 82 | log.info("transPinYouRequestBOList size is {}",transPinYouRequestBOList.size()); |
92 | 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 |
@@ -39,12 +39,19 @@ | @@ -39,12 +39,19 @@ | ||
39 | }); | 39 | }); |
40 | 40 | ||
41 | function getId() { | 41 | function getId() { |
42 | - var params = {}; | 42 | + var params = getParam("searchForm"); |
43 | params["unionType"] = unionType; | 43 | params["unionType"] = unionType; |
44 | return params; | 44 | return params; |
45 | } | 45 | } |
46 | 46 | ||
47 | }); | 47 | }); |
48 | 48 | ||
49 | - | 49 | + function getParam(table) { |
50 | + var paramsArray = $("#"+table+"").serializeArray(); | ||
51 | + var params = {}; | ||
52 | + for (var i = 0; i < paramsArray.length; i++) { | ||
53 | + params[paramsArray[i].name] = paramsArray[i].value; | ||
54 | + } | ||
55 | + return params; | ||
56 | + } | ||
50 | </script> | 57 | </script> |
@@ -343,14 +343,21 @@ | @@ -343,14 +343,21 @@ | ||
343 | function showActivateHour(id) { | 343 | function showActivateHour(id) { |
344 | unionType = id; | 344 | unionType = id; |
345 | var div = $("<div>").appendTo($(window.self.document.body)); | 345 | var div = $("<div>").appendTo($(window.self.document.body)); |
346 | + var params = getParam("searchForm"); | ||
347 | + params['unionType'] = $(this).attr("dataId"); | ||
346 | window.self.$(div).myDialog({ | 348 | window.self.$(div).myDialog({ |
347 | modal : true, | 349 | modal : true, |
348 | collapsible : true, | 350 | collapsible : true, |
349 | cache : false, | 351 | cache : false, |
350 | - title : "每小时点击量", | 352 | + title : "每小时激活量", |
351 | width: 600, | 353 | width: 600, |
352 | height: 600, | 354 | height: 600, |
353 | - href: contextPath + "/admin/activateHour.html?unionType="+id, | 355 | + href: contextPath + "/admin/activateHour.html", |
356 | + queryParams: { | ||
357 | + unionType: id, | ||
358 | + activateTimeEnd:params['activateTimeEnd'] | ||
359 | + | ||
360 | + }, | ||
354 | buttons : [{ | 361 | buttons : [{ |
355 | id : "closeBtn", | 362 | id : "closeBtn", |
356 | text : "关闭", | 363 | text : "关闭", |
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