Authored by zhengwen.ge

品友

... ... @@ -27,7 +27,7 @@ public class PinYouServiceImpl implements IPinYouService {
static String PINYOU_VIEW_URL = "http://stats.ipinyou.com/madv?";
static String PINYOU_TRANS_URL = "http://stats.ipinyou.com/mcdv?";
static String PINYOU_TRANS_URL = "http://stats.ipinyou.com/mcvt?";
@Override
/**
... ... @@ -39,12 +39,14 @@ public class PinYouServiceImpl implements IPinYouService {
String advertiser = "MC.LF";
//操作系统信息
String os = requestBO.getOs();
os = ClientTypeEnum.IOS.getName();
//根据从大数据获取的IDFA,IMEI来判断是安卓还是IOS
String client_type = ClientTypeEnum.IOS.getName();
String idfa = requestBO.getIdfa();
String imei = requestBO.getImei();
if(StringUtils.isEmpty(idfa)){
client_type = ClientTypeEnum.ANDROID.getName();
os = ClientTypeEnum.ANDROID.getName();
}
//时间戳
int currentTime = DateUtil.getCurrentTimeSecond();
... ... @@ -67,13 +69,13 @@ public class PinYouServiceImpl implements IPinYouService {
.append("&ts=").append(currentTime)
.append("&jp=1").append("&ip=").append(ip)
.append("&event=").append(event)
.append("&event_vaule").append(event_value).append("&df=0");
.append("&event_vaule=").append(event_value).append("&df=0");
String url = null;
if(event_value.equals(EnentValueEnum.ADD_CART.getName())||event_value.equals(EnentValueEnum.VIEW_ITEM.getName())){
stringBuffer= stringBuffer.append("&p").append(event_value);
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)){
stringBuffer = stringBuffer.append("&user_id").append(user_id);
stringBuffer = stringBuffer.append("&user_id=").append(user_id);
}
if(client_type.equalsIgnoreCase(ClientTypeEnum.ANDROID.getName())){
//如果是浏览商品和加入购物车则需要传p=商品编号
... ... @@ -96,10 +98,12 @@ public class PinYouServiceImpl implements IPinYouService {
String os = requestBO.getOs();
//根据从大数据获取的IDFA,IMEI来判断是安卓还是IOS
String client_type = ClientTypeEnum.IOS.getName();
os=ClientTypeEnum.IOS.getName();
String idfa = requestBO.getIdfa();
String imei = requestBO.getImei();
if(StringUtils.isEmpty(idfa)){
client_type = ClientTypeEnum.ANDROID.getName();
os=ClientTypeEnum.ANDROID.getName();
}
//时间戳
int currentTime = DateUtil.getCurrentTimeSecond();
... ... @@ -120,7 +124,7 @@ public class PinYouServiceImpl implements IPinYouService {
.append("&ts=").append(currentTime)
.append("&ip=").append(ip)
.append("&df=0").append("&user_id=")
.append(user_id).append("&order").append(order)
.append(user_id).append("&order=").append(order)
.append("&money=").append(money)
.append("&plist=").append(plist);
String url = null;
... ...
... ... @@ -11,6 +11,7 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/**
... ... @@ -20,9 +21,6 @@ import java.util.List;
@Component
public class PinYouTask {
@Autowired
private RedisListCache redisListCache;
private static final String UNION_VIEW_KEY = "union:pinyou:view";
private static final String UNION_TRANS_KEY = "union:pinyou:trans";
... ... @@ -30,19 +28,57 @@ public class PinYouTask {
@Resource
IPinYouService pinYouService;
@Scheduled(cron = "0 0/10 * * * ?")
@Autowired
private RedisListCache redisListCache;
@Scheduled(cron = "0/10 * * * * ?")
public void run(){
//从redis里面获取大数据的数据
List<ViewPinYouRequestBO> viewPinYouRequestBOList = redisListCache.rightPop(UNION_VIEW_KEY, List.class);
Long viewSize = redisListCache.size(UNION_VIEW_KEY);
Long transSize = redisListCache.size(UNION_TRANS_KEY);
List<ViewPinYouRequestBO> viewPinYouRequestBOList = new ArrayList<>();
int viewSizeInt = viewSize == null ? 0 : viewSize.intValue();
int transSizeInt = transSize == null ? 0:transSize.intValue();
List<TransPinYouRequestBO> transPinYouRequestBOList = new ArrayList<>();
List<TransPinYouRequestBO> transPinYouRequestBOList = redisListCache.rightPop(UNION_TRANS_KEY,List.class);
//将取出来的值按照品友的要求发给品友
if(viewSizeInt>0){
for(int i=0; i < viewSizeInt; i++){
viewPinYouRequestBOList = redisListCache.rightPop(UNION_VIEW_KEY, List.class);
}
}
if(transSizeInt>0){
for(int i=0; i < transSizeInt; i++){
transPinYouRequestBOList = redisListCache.rightPop(UNION_TRANS_KEY, List.class);
}
}
// //将取出来的值按照品友的要求发给品友
// ViewPinYouRequestBO viewPinYouRequestBO = new ViewPinYouRequestBO();
// viewPinYouRequestBOList = new ArrayList<>();
// viewPinYouRequestBO.setImei("aea6497538a822838d07661b89a18c5e");
// viewPinYouRequestBO.setEvent("viewItem");
// viewPinYouRequestBO.setEvent_value("387650");
// viewPinYouRequestBO.setUser_id("1357821");
// viewPinYouRequestBO.setIp("172.16.6.153");
// viewPinYouRequestBO.setOs("iphone");
// viewPinYouRequestBOList.add(viewPinYouRequestBO);
if(CollectionUtils.isNotEmpty(viewPinYouRequestBOList)){
for(ViewPinYouRequestBO requestBO:viewPinYouRequestBOList){
sendView(requestBO);
}
}
if(CollectionUtils.isNotEmpty(viewPinYouRequestBOList)){
// TransPinYouRequestBO transPinYouRequest = new TransPinYouRequestBO();
// transPinYouRequest.setImei("aea6497538a822838d07661b89a18c5e");
// transPinYouRequest.setOs("iphone");
// transPinYouRequest.setMoney("20");
// transPinYouRequest.setOrderStatus("1");
// transPinYouRequest.setPlist("2999,2;3000,3");
// transPinYouRequest.setIp("172.16.6.153");
// transPinYouRequest.setUser_id("13054");
// transPinYouRequest.setOrder("342321");
// transPinYouRequestBOList = new ArrayList<>();
// transPinYouRequestBOList.add(transPinYouRequest);
if(CollectionUtils.isNotEmpty(transPinYouRequestBOList)){
for(TransPinYouRequestBO transPinYouRequestBO:transPinYouRequestBOList){
sendTrans(transPinYouRequestBO);
}
... ...
... ... @@ -31,6 +31,10 @@ redis.proxy.address=test-bigdata-redis-1903805580.cn-north-1.elb.amazonaws.com.c
redis.proxy.port=6379
redis.proxy.auth=
redis.notsync.twemproxy.addresses=test-bigdata-redis-1903805580.cn-north-1.elb.amazonaws.com.cn:6379
redis.notsync.twemproxy.auth=
redis.notsync.twemproxy.database=1
########## common rabbitmq ##########
#aws
... ...