Authored by zhengwen.ge

品友

@@ -27,7 +27,7 @@ public class PinYouServiceImpl implements IPinYouService { @@ -27,7 +27,7 @@ public class PinYouServiceImpl implements IPinYouService {
27 27
28 static String PINYOU_VIEW_URL = "http://stats.ipinyou.com/madv?"; 28 static String PINYOU_VIEW_URL = "http://stats.ipinyou.com/madv?";
29 29
30 - static String PINYOU_TRANS_URL = "http://stats.ipinyou.com/mcdv?"; 30 + static String PINYOU_TRANS_URL = "http://stats.ipinyou.com/mcvt?";
31 31
32 @Override 32 @Override
33 /** 33 /**
@@ -39,12 +39,14 @@ public class PinYouServiceImpl implements IPinYouService { @@ -39,12 +39,14 @@ public class PinYouServiceImpl implements IPinYouService {
39 String advertiser = "MC.LF"; 39 String advertiser = "MC.LF";
40 //操作系统信息 40 //操作系统信息
41 String os = requestBO.getOs(); 41 String os = requestBO.getOs();
  42 + os = ClientTypeEnum.IOS.getName();
42 //根据从大数据获取的IDFA,IMEI来判断是安卓还是IOS 43 //根据从大数据获取的IDFA,IMEI来判断是安卓还是IOS
43 String client_type = ClientTypeEnum.IOS.getName(); 44 String client_type = ClientTypeEnum.IOS.getName();
44 String idfa = requestBO.getIdfa(); 45 String idfa = requestBO.getIdfa();
45 String imei = requestBO.getImei(); 46 String imei = requestBO.getImei();
46 if(StringUtils.isEmpty(idfa)){ 47 if(StringUtils.isEmpty(idfa)){
47 client_type = ClientTypeEnum.ANDROID.getName(); 48 client_type = ClientTypeEnum.ANDROID.getName();
  49 + os = ClientTypeEnum.ANDROID.getName();
48 } 50 }
49 //时间戳 51 //时间戳
50 int currentTime = DateUtil.getCurrentTimeSecond(); 52 int currentTime = DateUtil.getCurrentTimeSecond();
@@ -67,13 +69,13 @@ public class PinYouServiceImpl implements IPinYouService { @@ -67,13 +69,13 @@ public class PinYouServiceImpl implements IPinYouService {
67 .append("&ts=").append(currentTime) 69 .append("&ts=").append(currentTime)
68 .append("&jp=1").append("&ip=").append(ip) 70 .append("&jp=1").append("&ip=").append(ip)
69 .append("&event=").append(event) 71 .append("&event=").append(event)
70 - .append("&event_vaule").append(event_value).append("&df=0"); 72 + .append("&event_vaule=").append(event_value).append("&df=0");
71 String url = null; 73 String url = null;
72 - if(event_value.equals(EnentValueEnum.ADD_CART.getName())||event_value.equals(EnentValueEnum.VIEW_ITEM.getName())){  
73 - stringBuffer= stringBuffer.append("&p").append(event_value); 74 + if(event.equals(EnentValueEnum.ADD_CART.getName())||event.equals(EnentValueEnum.VIEW_ITEM.getName())){
  75 + stringBuffer= stringBuffer.append("&p=").append(event_value);
74 } 76 }
75 if(StringUtils.isNotEmpty(user_id)){ 77 if(StringUtils.isNotEmpty(user_id)){
76 - stringBuffer = stringBuffer.append("&user_id").append(user_id); 78 + stringBuffer = stringBuffer.append("&user_id=").append(user_id);
77 } 79 }
78 if(client_type.equalsIgnoreCase(ClientTypeEnum.ANDROID.getName())){ 80 if(client_type.equalsIgnoreCase(ClientTypeEnum.ANDROID.getName())){
79 //如果是浏览商品和加入购物车则需要传p=商品编号 81 //如果是浏览商品和加入购物车则需要传p=商品编号
@@ -96,10 +98,12 @@ public class PinYouServiceImpl implements IPinYouService { @@ -96,10 +98,12 @@ public class PinYouServiceImpl implements IPinYouService {
96 String os = requestBO.getOs(); 98 String os = requestBO.getOs();
97 //根据从大数据获取的IDFA,IMEI来判断是安卓还是IOS 99 //根据从大数据获取的IDFA,IMEI来判断是安卓还是IOS
98 String client_type = ClientTypeEnum.IOS.getName(); 100 String client_type = ClientTypeEnum.IOS.getName();
  101 + os=ClientTypeEnum.IOS.getName();
99 String idfa = requestBO.getIdfa(); 102 String idfa = requestBO.getIdfa();
100 String imei = requestBO.getImei(); 103 String imei = requestBO.getImei();
101 if(StringUtils.isEmpty(idfa)){ 104 if(StringUtils.isEmpty(idfa)){
102 client_type = ClientTypeEnum.ANDROID.getName(); 105 client_type = ClientTypeEnum.ANDROID.getName();
  106 + os=ClientTypeEnum.ANDROID.getName();
103 } 107 }
104 //时间戳 108 //时间戳
105 int currentTime = DateUtil.getCurrentTimeSecond(); 109 int currentTime = DateUtil.getCurrentTimeSecond();
@@ -120,7 +124,7 @@ public class PinYouServiceImpl implements IPinYouService { @@ -120,7 +124,7 @@ public class PinYouServiceImpl implements IPinYouService {
120 .append("&ts=").append(currentTime) 124 .append("&ts=").append(currentTime)
121 .append("&ip=").append(ip) 125 .append("&ip=").append(ip)
122 .append("&df=0").append("&user_id=") 126 .append("&df=0").append("&user_id=")
123 - .append(user_id).append("&order").append(order) 127 + .append(user_id).append("&order=").append(order)
124 .append("&money=").append(money) 128 .append("&money=").append(money)
125 .append("&plist=").append(plist); 129 .append("&plist=").append(plist);
126 String url = null; 130 String url = null;
@@ -11,6 +11,7 @@ import org.springframework.scheduling.annotation.Scheduled; @@ -11,6 +11,7 @@ import org.springframework.scheduling.annotation.Scheduled;
11 import org.springframework.stereotype.Component; 11 import org.springframework.stereotype.Component;
12 12
13 import javax.annotation.Resource; 13 import javax.annotation.Resource;
  14 +import java.util.ArrayList;
14 import java.util.List; 15 import java.util.List;
15 16
16 /** 17 /**
@@ -20,9 +21,6 @@ import java.util.List; @@ -20,9 +21,6 @@ import java.util.List;
20 @Component 21 @Component
21 public class PinYouTask { 22 public class PinYouTask {
22 23
23 - @Autowired  
24 - private RedisListCache redisListCache;  
25 -  
26 private static final String UNION_VIEW_KEY = "union:pinyou:view"; 24 private static final String UNION_VIEW_KEY = "union:pinyou:view";
27 25
28 private static final String UNION_TRANS_KEY = "union:pinyou:trans"; 26 private static final String UNION_TRANS_KEY = "union:pinyou:trans";
@@ -30,19 +28,57 @@ public class PinYouTask { @@ -30,19 +28,57 @@ public class PinYouTask {
30 @Resource 28 @Resource
31 IPinYouService pinYouService; 29 IPinYouService pinYouService;
32 30
33 - @Scheduled(cron = "0 0/10 * * * ?") 31 + @Autowired
  32 + private RedisListCache redisListCache;
  33 +
  34 + @Scheduled(cron = "0/10 * * * * ?")
34 public void run(){ 35 public void run(){
35 //从redis里面获取大数据的数据 36 //从redis里面获取大数据的数据
36 - List<ViewPinYouRequestBO> viewPinYouRequestBOList = redisListCache.rightPop(UNION_VIEW_KEY, List.class); 37 + Long viewSize = redisListCache.size(UNION_VIEW_KEY);
  38 + Long transSize = redisListCache.size(UNION_TRANS_KEY);
  39 + List<ViewPinYouRequestBO> viewPinYouRequestBOList = new ArrayList<>();
  40 + int viewSizeInt = viewSize == null ? 0 : viewSize.intValue();
  41 + int transSizeInt = transSize == null ? 0:transSize.intValue();
  42 + List<TransPinYouRequestBO> transPinYouRequestBOList = new ArrayList<>();
37 43
38 - List<TransPinYouRequestBO> transPinYouRequestBOList = redisListCache.rightPop(UNION_TRANS_KEY,List.class);  
39 - //将取出来的值按照品友的要求发给品友 44 + if(viewSizeInt>0){
  45 + for(int i=0; i < viewSizeInt; i++){
  46 + viewPinYouRequestBOList = redisListCache.rightPop(UNION_VIEW_KEY, List.class);
  47 + }
  48 + }
  49 + if(transSizeInt>0){
  50 + for(int i=0; i < transSizeInt; i++){
  51 + transPinYouRequestBOList = redisListCache.rightPop(UNION_TRANS_KEY, List.class);
  52 + }
  53 + }
  54 +
  55 +// //将取出来的值按照品友的要求发给品友
  56 +// ViewPinYouRequestBO viewPinYouRequestBO = new ViewPinYouRequestBO();
  57 +// viewPinYouRequestBOList = new ArrayList<>();
  58 +// viewPinYouRequestBO.setImei("aea6497538a822838d07661b89a18c5e");
  59 +// viewPinYouRequestBO.setEvent("viewItem");
  60 +// viewPinYouRequestBO.setEvent_value("387650");
  61 +// viewPinYouRequestBO.setUser_id("1357821");
  62 +// viewPinYouRequestBO.setIp("172.16.6.153");
  63 +// viewPinYouRequestBO.setOs("iphone");
  64 +// viewPinYouRequestBOList.add(viewPinYouRequestBO);
40 if(CollectionUtils.isNotEmpty(viewPinYouRequestBOList)){ 65 if(CollectionUtils.isNotEmpty(viewPinYouRequestBOList)){
41 for(ViewPinYouRequestBO requestBO:viewPinYouRequestBOList){ 66 for(ViewPinYouRequestBO requestBO:viewPinYouRequestBOList){
42 sendView(requestBO); 67 sendView(requestBO);
43 } 68 }
44 } 69 }
45 - if(CollectionUtils.isNotEmpty(viewPinYouRequestBOList)){ 70 +// TransPinYouRequestBO transPinYouRequest = new TransPinYouRequestBO();
  71 +// transPinYouRequest.setImei("aea6497538a822838d07661b89a18c5e");
  72 +// transPinYouRequest.setOs("iphone");
  73 +// transPinYouRequest.setMoney("20");
  74 +// transPinYouRequest.setOrderStatus("1");
  75 +// transPinYouRequest.setPlist("2999,2;3000,3");
  76 +// transPinYouRequest.setIp("172.16.6.153");
  77 +// transPinYouRequest.setUser_id("13054");
  78 +// transPinYouRequest.setOrder("342321");
  79 +// transPinYouRequestBOList = new ArrayList<>();
  80 +// transPinYouRequestBOList.add(transPinYouRequest);
  81 + if(CollectionUtils.isNotEmpty(transPinYouRequestBOList)){
46 for(TransPinYouRequestBO transPinYouRequestBO:transPinYouRequestBOList){ 82 for(TransPinYouRequestBO transPinYouRequestBO:transPinYouRequestBOList){
47 sendTrans(transPinYouRequestBO); 83 sendTrans(transPinYouRequestBO);
48 } 84 }
@@ -31,6 +31,10 @@ redis.proxy.address=test-bigdata-redis-1903805580.cn-north-1.elb.amazonaws.com.c @@ -31,6 +31,10 @@ redis.proxy.address=test-bigdata-redis-1903805580.cn-north-1.elb.amazonaws.com.c
31 redis.proxy.port=6379 31 redis.proxy.port=6379
32 redis.proxy.auth= 32 redis.proxy.auth=
33 33
  34 +redis.notsync.twemproxy.addresses=test-bigdata-redis-1903805580.cn-north-1.elb.amazonaws.com.cn:6379
  35 +redis.notsync.twemproxy.auth=
  36 +redis.notsync.twemproxy.database=1
  37 +
34 38
35 ########## common rabbitmq ########## 39 ########## common rabbitmq ##########
36 #aws 40 #aws