Authored by chaogeng

Merge branch 'master' of http://git.yoho.cn/yoho30/yohobuy-union

... ... @@ -10,6 +10,7 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.yoho.unions.server.service.IPinYouService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -47,6 +48,9 @@ public class ActivateUnionRest {
static ExecutorService exe = Executors.newFixedThreadPool(10);
@Resource
IPinYouService pinYouService;
@Resource(name="unionServiceImpl")
IUnionService unionService;
... ... @@ -176,4 +180,15 @@ public class ActivateUnionRest {
activeDingdang.info(j.toString());
return new ActiveUnionResponseBO();
}
/**
* 给品友留的后门,如果定时任务没有启动,则通过curl调用接口,直接获取数据,并发送给品友
*/
@RequestMapping("/sendPinYou")
@ResponseBody
public UnionResponse sendPinYou(){
log.info("begin sendPinYou");
UnionResponse response = pinYouService.sendPinYou();
return response;
}
}
... ...
... ... @@ -14,10 +14,12 @@ public interface IPinYouService {
* 给品友发送访问数据
* @param requestBO
*/
UnionResponse sendViem(ViewPinYouRequestBO requestBO);
UnionResponse sendView(ViewPinYouRequestBO requestBO);
/**
* 给品友发送转化数据,主要是下单
*/
UnionResponse sendTrans(TransPinYouRequestBO requestBO);
UnionResponse sendPinYou();
}
... ...
... ... @@ -10,6 +10,7 @@ import com.yoho.unions.server.service.IFanliService;
import com.yoho.unions.server.service.IOrderPushService;
import com.yoho.unions.vo.OrderInfo;
import com.yoho.unions.vo.OrdersGood;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
... ... @@ -18,6 +19,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
... ... @@ -35,7 +38,7 @@ public class FanliServiceImpl implements IFanliService, IOrderPushService {
private static final String SHOP_KEY = "";
private static final String FANLI_URL = "http://union.fanli.com/dingdan/push?shopid=506";
private static final String FANLI_URL = "http://union.fanli.com/dingdan/push?shopid=690";
/**
* 推送订单
... ... @@ -48,6 +51,9 @@ public class FanliServiceImpl implements IFanliService, IOrderPushService {
Element rootElement = document.addElement("orders");
document.setRootElement(rootElement);
for (OrderInfo orderInfo : orderInfos) {
if (CollectionUtils.isEmpty(orderInfo.getOrdersGoods())) {
continue;
}
//订单信息
Element orderElement = rootElement.addElement("order");
//创建订单子节点
... ... @@ -66,6 +72,12 @@ public class FanliServiceImpl implements IFanliService, IOrderPushService {
try {
String resultXml = HttpUtils.httpPost(FANLI_URL, param).getRight();
logger.info("push order to fanli success.result is {}", resultXml);
//没有返参 再次发送
if (StringUtils.isEmpty(resultXml)) {
i++;
continue;
}
//跳出循环
i = 3;
} catch (Exception e) {
i++;
... ... @@ -81,10 +93,10 @@ public class FanliServiceImpl implements IFanliService, IOrderPushService {
* @param orderInfo
*/
private void creatOrderLeaf(Element orderElement, OrderInfo orderInfo) {
orderElement.addElement("s_id").setText("");
orderElement.addElement("s_id").setText("690");
orderElement.addElement("order_id_parent").setText(String.valueOf(orderInfo.getParentOrderCode()));
orderElement.addElement("order_id").setText(String.valueOf(orderInfo.getOrderCode()));
orderElement.addElement("order_time").setText(DateUtil.date2String(new Date(orderInfo.getOrderTime() * 1000), "yyyy-MM-dd HH:mm:ss"));
orderElement.addElement("order_time").setText(DateUtil.date2String(new Date(Long.valueOf(orderInfo.getOrderTime()) * 1000), "yyyy-MM-dd HH:mm:ss"));
orderElement.addElement("uid").setText(orderInfo.getThirdUid());
orderElement.addElement("uname").setText(orderInfo.getThirdUid() + "@51fanli");
orderElement.addElement("tc").setText(orderInfo.getTrackingCode());
... ... @@ -94,7 +106,7 @@ public class FanliServiceImpl implements IFanliService, IOrderPushService {
orderElement.addElement("lastmod").setText("");
orderElement.addElement("is_newbuyer").setText("");
orderElement.addElement("platform").setText(orderInfo.getOrderType());
orderElement.addElement("code").setText(getPassCode());
orderElement.addElement("code").setText("");
orderElement.addElement("remark").setText("");
}
... ... @@ -142,8 +154,8 @@ public class FanliServiceImpl implements IFanliService, IOrderPushService {
productElement.addElement("price").setText(String.valueOf(ordersGood.getLastPrice()));
productElement.addElement("real_pay_fee").setText(String.valueOf(ordersGood.getRealPayFee()));
productElement.addElement("refund_num").setText("0");
productElement.addElement("commission").setText("");
productElement.addElement("comm_type").setText("");
productElement.addElement("commission").setText(String.valueOf(ordersGood.getRealPayFee().multiply(new BigDecimal(0.03)).setScale(2, BigDecimal.ROUND_HALF_UP)));
productElement.addElement("comm_type").setText("A");
}
}
... ...
... ... @@ -14,6 +14,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
/**
... ... @@ -52,7 +53,7 @@ public class PanshiServiceImpl implements IOrderPushService {
param.put("orTime",DateUtil.date2String(new Date((long)orderInfo.getOrderTime() * 1000), "yyyy-MM-dd HH:mm:ss"));
param.put("code", orderInfo.getTrackingCode());
// param.put("code", "1|2|3|4|5|6"); 测试时code
param.put("orMoney", orderInfo.getOrderAmount());
BigDecimal orMoney = new BigDecimal(0);
if(orderInfo.getPayment().equals("2")){
param.put("psy","b"); //2=银联支付
}else if(orderInfo.getPayment().equals("3")){
... ... @@ -76,6 +77,7 @@ public class PanshiServiceImpl implements IOrderPushService {
param.put("proName", good.getProductName());
param.put("proCat", good.getSortName());
param.put("commRate", COMMRATE);
orMoney = good.getRealPayFee().multiply(new BigDecimal(good.getBuyNumber())).setScale(2, BigDecimal.ROUND_HALF_UP);
} else {
StringBuffer skns = new StringBuffer();
StringBuffer prices = new StringBuffer();
... ... @@ -85,13 +87,13 @@ public class PanshiServiceImpl implements IOrderPushService {
StringBuffer rates = new StringBuffer();
for (int i = 0; i < goods.size(); i++) {
skns.append(goods.get(i).getProductSkn() + "|");
prices.append(goods.get(i).getRealPayFee() + "|");
prices.append(goods.get(i).getRealPayFee().setScale(2, BigDecimal.ROUND_HALF_UP) + "|");
nums.append(goods.get(i).getBuyNumber() + "|");
names.append(goods.get(i).getProductName() + "|");
cats.append(goods.get(i).getSortName() + "|");
rates.append(COMMRATE + "|");
orMoney = orMoney.add(goods.get(i).getRealPayFee().multiply(new BigDecimal(goods.get(i).getBuyNumber()))).setScale(2, BigDecimal.ROUND_HALF_UP);
}
param.put("proNo", skns.substring(0, skns.length() - 1));
param.put("proPrice", prices.substring(0, prices.length() - 1));
param.put("proNum", nums.substring(0, nums.length() - 1));
... ... @@ -99,6 +101,7 @@ public class PanshiServiceImpl implements IOrderPushService {
param.put("proCat", cats.substring(0, cats.length() - 1));
param.put("commRate", rates.substring(0, rates.length() - 1));
}
param.put("orMoney",orMoney.doubleValue());
Pair<Integer, String> pair = null;
try {
logger.info("pushOrder: url is {}, param is {}", URL, param);
... ...
... ... @@ -6,16 +6,21 @@ import com.yoho.service.model.union.request.ViewPinYouRequestBO;
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.redis.RedisListCache;
import com.yoho.unions.common.utils.DateUtil;
import com.yoho.unions.common.utils.HttpUtils;
import com.yoho.unions.server.service.IPinYouService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.List;
/**
* Created by yoho on 2016/11/15.
... ... @@ -29,12 +34,56 @@ public class PinYouServiceImpl implements IPinYouService {
static String PINYOU_TRANS_URL = "http://stats.ipinyou.com/mcvt?";
private static final String UNION_VIEW_KEY = "union:pinyou:view";
private static final String UNION_TRANS_KEY = "union:pinyou:trans";
@Autowired
private RedisListCache redisListCache;
@Override
public UnionResponse sendPinYou() {
//从redis里面获取大数据的数据
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<>();
if (viewSizeInt > 0) {
for (int i = 0; i < viewSizeInt; i++) {
ViewPinYouRequestBO viewPinYouRequestBO = redisListCache.rightPop(UNION_VIEW_KEY, ViewPinYouRequestBO.class);
viewPinYouRequestBOList.add(viewPinYouRequestBO);
}
}
if (transSizeInt > 0) {
for (int i = 0; i < transSizeInt; i++) {
TransPinYouRequestBO transPinYouRequestBO = redisListCache.rightPop(UNION_TRANS_KEY, TransPinYouRequestBO.class);
transPinYouRequestBOList.add(transPinYouRequestBO);
}
}
if (CollectionUtils.isNotEmpty(viewPinYouRequestBOList)) {
for (ViewPinYouRequestBO requestBO : viewPinYouRequestBOList) {
sendView(requestBO);
}
}
if (CollectionUtils.isNotEmpty(transPinYouRequestBOList)) {
for (TransPinYouRequestBO transPinYouRequestBO : transPinYouRequestBOList) {
sendTrans(transPinYouRequestBO);
}
}
return new UnionResponse();
}
/**
* jp:启动参数,固定位1
*df:debug flag 固定0
* df:debug flag 固定0
*/
public UnionResponse sendViem(ViewPinYouRequestBO requestBO){
@Override
public UnionResponse sendView(ViewPinYouRequestBO requestBO) {
//广告主信息
String advertiser = "MC.LF";
//操作系统信息
... ... @@ -44,12 +93,15 @@ public class PinYouServiceImpl implements IPinYouService {
String client_type = ClientTypeEnum.IOS.getName();
String idfa = requestBO.getIdfa();
String imei = requestBO.getImei();
if(idfa.equals("")||StringUtils.isEmpty(idfa)){
if (idfa.equals("") || StringUtils.isEmpty(idfa)) {
client_type = ClientTypeEnum.ANDROID.getName();
os = ClientTypeEnum.ANDROID.getName();
}
//时间戳
int currentTime = DateUtil.getCurrentTimeSecond();
String ts = requestBO.getTs();
if (StringUtils.isEmpty(ts)) {
ts = String.valueOf(DateUtil.getCurrentTimeSecond() * 1000);
}
//启动参数,固定位1
String jp = "1";
//用户id
... ... @@ -67,23 +119,23 @@ public class PinYouServiceImpl implements IPinYouService {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer = stringBuffer.append(PINYOU_VIEW_URL).append("a=")
.append(advertiser).append("&os=").append(os)
.append("&ts=").append(currentTime)
.append("&ts=").append(ts)
.append("&jp=1").append("&ip=").append(ip)
.append("&event=").append(event)
.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 (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]+")){
if (StringUtils.isNotEmpty(user_id) && user_id.matches("[0-9]+")) {
stringBuffer = stringBuffer.append("&user_id=").append(user_id);
}
if(client_type.equalsIgnoreCase(ClientTypeEnum.ANDROID.getName())){
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())){
if (client_type.equalsIgnoreCase(ClientTypeEnum.IOS.getName())) {
String iam = MD5.md5(idfa);
stringBuffer = stringBuffer.append("&iam=").append(iam);
}
... ... @@ -92,22 +144,25 @@ public class PinYouServiceImpl implements IPinYouService {
return response;
}
public UnionResponse sendTrans(TransPinYouRequestBO requestBO){
public UnionResponse sendTrans(TransPinYouRequestBO requestBO) {
//广告主信息
String advertiser = "MC.LF";
//操作系统信息
String os = requestBO.getOs();
//根据从大数据获取的IDFA,IMEI来判断是安卓还是IOS
String client_type = ClientTypeEnum.IOS.getName();
os=ClientTypeEnum.IOS.getName();
os = ClientTypeEnum.IOS.getName();
String idfa = requestBO.getIdfa();
String imei = requestBO.getImei();
if(idfa.equals("")||StringUtils.isEmpty(idfa)){
if (idfa.equals("") || StringUtils.isEmpty(idfa)) {
client_type = ClientTypeEnum.ANDROID.getName();
os=ClientTypeEnum.ANDROID.getName();
os = ClientTypeEnum.ANDROID.getName();
}
//时间戳
int currentTime = DateUtil.getCurrentTimeSecond();
String ts = requestBO.getTs();
if (StringUtils.isEmpty(ts)) {
ts = String.valueOf(DateUtil.getCurrentTimeSecond() * 1000);
}
String order = requestBO.getOrder();
String money = requestBO.getMoney();
... ... @@ -122,27 +177,27 @@ public class PinYouServiceImpl implements IPinYouService {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer = stringBuffer.append(PINYOU_TRANS_URL).append("a=")
.append(advertiser).append("&os=").append(os)
.append("&ts=").append(currentTime)
.append("&ts=").append(ts)
.append("&ip=").append(ip)
.append("&df=0").append("&order=").append(order)
.append("&money=").append(money)
.append("&plist=").append(plist);
String url = null;
if(client_type.equalsIgnoreCase(ClientTypeEnum.ANDROID.getName())){
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())){
if (client_type.equalsIgnoreCase(ClientTypeEnum.IOS.getName())) {
String iam = MD5.md5(idfa);
stringBuffer = stringBuffer.append("&iam=").append(iam);
}
if(StringUtils.isNotEmpty(user_id)&& user_id.matches("[0-9]+")){
if (StringUtils.isNotEmpty(user_id) && user_id.matches("[0-9]+")) {
stringBuffer = stringBuffer.append("&user_id=").append(user_id);
}
if(orderStatus.equals("1")||orderStatus.equals("2")){
if (orderStatus.equals("1") || orderStatus.equals("2")) {
stringBuffer = stringBuffer.append("&gl=9466");
}else{
} else {
stringBuffer = stringBuffer.append("&gl=334");
}
url = stringBuffer.toString();
... ... @@ -150,9 +205,9 @@ public class PinYouServiceImpl implements IPinYouService {
return response;
}
private UnionResponse sendUrl(String url){
log.info("sendUrl url is {}",url);
try{
private UnionResponse sendUrl(String url) {
log.info("sendUrl url is {}", url);
try {
url = URLDecoder.decode(url, "UTF-8");
Pair<Integer, String> pair = HttpUtils.httpGet(url);
log.info("activateUnion call union success url={}, and result={}", url, pair);
... ... @@ -160,9 +215,9 @@ public class PinYouServiceImpl implements IPinYouService {
log.warn("callback error with request={}", url);
return new UnionResponse(204, "callback error");
}
}catch (Exception e){
} catch (Exception e) {
log.error("callback error with request={}", url, e.getMessage());
}
return new UnionResponse();
return new UnionResponse();
}
}
... ...
... ... @@ -11,12 +11,17 @@ import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URLDecoder;
import java.net.URLEncoder;
@Service
public class RedirectServiceImpl implements IRedirectService{
public class RedirectServiceImpl implements IRedirectService {
Logger logger = LoggerFactory.getLogger(RedirectServiceImpl.class);
... ... @@ -37,18 +42,18 @@ public class RedirectServiceImpl implements IRedirectService{
return;
}
String channelId = uionReqVO.getChannel_id();
if(StringUtils.isEmpty(uionReqVO.getChannel_id())){
if (StringUtils.isEmpty(uionReqVO.getChannel_id())) {
logger.warn("jump: channelId is null, requst param is {}", uionReqVO);
return;
}
if(StringUtils.isEmpty(uionReqVO.getTracking_code())){
if (StringUtils.isEmpty(uionReqVO.getTracking_code())) {
logger.warn("jump: trackCode is null, requst param is {}", uionReqVO);
return;
}
String redirectUrl = "";
if(channelId.equals(SourceEnum.PANSHI.getValue())){
if (channelId.equals(SourceEnum.PANSHI.getValue())) {
redirectUrl = this.builderUrlForPanshi(uionReqVO);
}else if(channelId.equals(SourceEnum.FANLI_WAP.getValue()) || channelId.equals(SourceEnum.FANLI_WEB.getValue())){
} else if ("51fanli".equals(channelId)) {
redirectUrl = this.builderUrlForFanli(uionReqVO);
}
response.setStatus(301);
... ... @@ -58,13 +63,13 @@ public class RedirectServiceImpl implements IRedirectService{
}
}
private String builderUrlForPanshi(UnionReqVO uionReqVO){
private String builderUrlForPanshi(UnionReqVO uionReqVO) {
String param = this.generateReqParam(uionReqVO);
StringBuffer targetUrl = new StringBuffer(uionReqVO.getTarget_url());
targetUrl = StringUtils.isEmpty(targetUrl) ? new StringBuffer(WAP_URL) : targetUrl;
if(targetUrl.toString().contains("?")){
if (targetUrl.toString().contains("?")) {
targetUrl.append("&utm_source=").append(uionReqVO.getUtm_source()).append("&utm_medium=").append(uionReqVO.getUtm_medium()).append("&utm_campaign=").append(uionReqVO.getUtm_campaign());
}else{
} else {
targetUrl.append("?utm_source=").append(uionReqVO.getUtm_source()).append("&utm_medium=").append(uionReqVO.getUtm_medium()).append("&utm_campaign=").append(uionReqVO.getUtm_campaign());
}
... ... @@ -81,39 +86,72 @@ public class RedirectServiceImpl implements IRedirectService{
return urlBuilder.toString();
}
private String builderUrlForFanli(UnionReqVO uionReqVO){
private String builderUrlForFanli(UnionReqVO uionReqVO) {
//解析targetUrl
praseTargetUrl(uionReqVO);
String redirectUrl = "";
String param = this.generateReqParam(uionReqVO);
String targetUrl = uionReqVO.getTarget_url();
if(SourceEnum.FANLI_WEB.getValue().equals(uionReqVO.getChannel_id())){
StringBuilder targetUrl = new StringBuilder();
if (SourceEnum.FANLI_WEB.getValue().equals(uionReqVO.getUnion_type())) {
redirectUrl = WEB_REDIRECT_URL;
targetUrl = StringUtils.isEmpty(targetUrl) ? WEB_URL : targetUrl;
targetUrl.append(StringUtils.isEmpty(uionReqVO.getTarget_url()) ? WEB_URL : uionReqVO.getTarget_url());
}
if(SourceEnum.FANLI_WAP.getValue().equals(uionReqVO.getChannel_id())){
if (SourceEnum.FANLI_WAP.getValue().equals(uionReqVO.getUnion_type())) {
redirectUrl = WAP_REDIRECT_URL;
targetUrl = StringUtils.isEmpty(targetUrl) ? WAP_URL : targetUrl;
targetUrl.append(StringUtils.isEmpty(targetUrl) ? WAP_URL : uionReqVO.getTarget_url());
}
targetUrl.append("?union_type=").append(uionReqVO.getUnion_type()).append("&utm_source=").append(uionReqVO.getUtm_source())
.append("&utm_medium=").append(uionReqVO.getUtm_medium()).append("&utm_campaign=").append(uionReqVO.getUtm_campaign());
String newTargetUrl = targetUrl.toString();
try {
param = URLEncoder.encode(param, "UTF-8");
targetUrl = URLEncoder.encode(targetUrl, "UTF-8");
newTargetUrl = URLEncoder.encode(newTargetUrl, "UTF-8");
} catch (UnsupportedEncodingException e) {
logger.warn("builderUrlForFanli: urlEncode failed: request param is {}", uionReqVO);
}
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(redirectUrl).append("?_QYH_UNION=");
urlBuilder.append(param).append("&target=");
urlBuilder.append(targetUrl);
urlBuilder.append(newTargetUrl);
return urlBuilder.toString();
}
private String generateReqParam(UnionReqVO uionReqVO){
/**
* 解析url
*
* @param uionReqVO
*/
private void praseTargetUrl(UnionReqVO uionReqVO) {
String url = "";
try {
url = URLDecoder.decode(uionReqVO.getTarget_url(), "UTF-8");
} catch (UnsupportedEncodingException e) {
logger.warn("decode target url fail! target_url {} e {}", uionReqVO.getTarget_url(), e);
}
String[] arr = url.split("\\?");
uionReqVO.setTarget_url(arr[0]);
PropertyDescriptor property = null;
for (String params : arr[1].split("&")) {
String[] param = params.split("=");
try {
property = new PropertyDescriptor(param[0], UnionReqVO.class);
//获取set方法
Method method = property.getWriteMethod();
//调用set方法
method.invoke(uionReqVO, param[1]);
} catch (Exception e) {
logger.warn("prase target url fail! target_url {} e {}", url, e);
}
}
}
private String generateReqParam(UnionReqVO uionReqVO) {
JSONObject param = new JSONObject();
param.put("client_id",uionReqVO.getChannel_id());
param.put("channel_code",uionReqVO.getTracking_code());
param.put("channel",uionReqVO.getChannel_id());
param.put("fl_uid",uionReqVO.getU_id());
param.put("go_url",uionReqVO.getTarget_url());
param.put("client_id", uionReqVO.getUnion_type());
param.put("channel_code", uionReqVO.getTracking_code());
param.put("channel", uionReqVO.getUnion_type());
param.put("fl_uid", uionReqVO.getU_id());
param.put("go_url", uionReqVO.getTarget_url());
return param.toString();
}
}
... ...
... ... @@ -6,6 +6,8 @@ import com.yoho.unions.common.redis.RedisListCache;
import com.yoho.unions.dal.model.UnionOrders;
import com.yoho.unions.server.service.IPinYouService;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
... ... @@ -21,6 +23,7 @@ import java.util.List;
@Component
public class PinYouTask {
static Logger log = LoggerFactory.getLogger(PinYouTask.class);
private static final String UNION_VIEW_KEY = "union:pinyou:view";
private static final String UNION_TRANS_KEY = "union:pinyou:trans";
... ... @@ -31,7 +34,10 @@ public class PinYouTask {
@Autowired
private RedisListCache redisListCache;
@Scheduled(cron = "0/10 * * * * ?")
/**
* 每天早上6点执行
*/
@Scheduled(cron = "0 0 6 * * ?")
public void run(){
//从redis里面获取大数据的数据
Long viewSize = redisListCache.size(UNION_VIEW_KEY);
... ... @@ -54,33 +60,15 @@ public class PinYouTask {
}
}
// //将取出来的值按照品友的要求发给品友
// 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)){
log.info("viewPinYouRequestBOList size is {}",viewPinYouRequestBOList.size());
for(ViewPinYouRequestBO requestBO:viewPinYouRequestBOList){
sendView(requestBO);
}
}
// 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)){
log.info("transPinYouRequestBOList size is {}",transPinYouRequestBOList.size());
for(TransPinYouRequestBO transPinYouRequestBO:transPinYouRequestBOList){
sendTrans(transPinYouRequestBO);
}
... ... @@ -89,7 +77,7 @@ public class PinYouTask {
//给品友推送访问数据
private void sendView(ViewPinYouRequestBO requestBO){
pinYouService.sendViem(requestBO);
pinYouService.sendView(requestBO);
}
//给品友推送转化数据
... ...