Authored by linlong

Merge branch 'master' into hotfix_0307

... ... @@ -332,7 +332,14 @@ public class ClickUnionRest {
bo.setInterfaceType("addUnion4Jump_android");
}
StringBuffer stringBuffer = new StringBuffer();
String bean = stringBuffer.append("UnionServiceImpl").append("_").append(bo.getUnion_type()).toString();
//根据union_type区分不同的厂商
String union_type = bo.getUnion_type();
//先去union_type_match表里面查看,是否有对应关系
UnionTypeMatch unionTypeMatch = unionTypeMatchDAO.selectByPrimaryKey(Long.valueOf(union_type));
if(unionTypeMatch!=null && StringUtils.isNotEmpty(String.valueOf(unionTypeMatch.getUnionTypeMatch()))){
union_type = String.valueOf(unionTypeMatch.getUnionTypeMatch());
}
String bean = stringBuffer.append("UnionServiceImpl").append("_").append(union_type).toString();
boolean containsBean = SpringContextUtil.containsBean(bean);
if (containsBean) {
IUnionService service = SpringContextUtil.getBean(bean, IUnionService.class);
... ...
... ... @@ -29,7 +29,7 @@ public class PinYouActServiceImpl extends UnionServiceImpl implements IUnionServ
requestBO.setImei(activateUnionRequestBO.getImei());
requestBO.setClientIp(activateUnionRequestBO.getClientIp());
//对url进行拼装
log.info("getCallbackUrl request is {}",requestBO);
log.info("getPinyouCallbackUrl request is {}",requestBO);
return urlEode(requestBO);
}
... ... @@ -68,7 +68,7 @@ public class PinYouActServiceImpl extends UnionServiceImpl implements IUnionServ
.append(currentTime).append("&gl=6877")
.append("&df=0").append("&ip=").append(ip).toString();
}
log.info("urlEode url is {}", url);
log.info("pinYou urlEode url is {}", url);
return url;
}
}
... ...
... ... @@ -131,7 +131,7 @@ public class PinYouServiceImpl implements IPinYouService {
stringBuffer = stringBuffer.append("&p=").append(event_value);
}
if (StringUtils.isNotEmpty(user_id) && user_id.matches("[0-9]+")) {
stringBuffer = stringBuffer.append("&user_id=").append(user_id);
stringBuffer = stringBuffer.append("&uid=").append(user_id);
}
if (client_type.equalsIgnoreCase(ClientTypeEnum.ANDROID.getName())) {
//如果是浏览商品和加入购物车则需要传p=商品编号
... ... @@ -196,7 +196,7 @@ public class PinYouServiceImpl implements IPinYouService {
stringBuffer = stringBuffer.append("&iam=").append(iam);
}
if (StringUtils.isNotEmpty(user_id) && user_id.matches("[0-9]+")) {
stringBuffer = stringBuffer.append("&user_id=").append(user_id);
stringBuffer = stringBuffer.append("&uid=").append(user_id);
}
if (orderStatus.equals("1") || orderStatus.equals("2")) {
stringBuffer = stringBuffer.append("&gl=9466");
... ... @@ -209,13 +209,13 @@ public class PinYouServiceImpl implements IPinYouService {
}
private UnionResponse sendUrl(String url) {
log.info("sendUrl url is {}", url);
log.info("pinyou sendUrl url is {}", url);
try {
url = URLDecoder.decode(url, "UTF-8");
Pair<Integer, String> pair = HttpUtils.httpGet(url);
log.info("pinyou sendUrl union success url={}, and result={}", url, pair);
if (pair.getLeft() != 200) {
log.warn("callback error with request={}", url);
log.warn("pinyou callback error with request={}", url);
return new UnionResponse(204, "callback error");
}
} catch (Exception e) {
... ...
... ... @@ -316,7 +316,18 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
}
}
}
if (ClientTypeEnum.ANDROID.getName().equals(request.getClient_type())
&& StringUtils.isNotEmpty(td)
&& StringUtils.isEmpty(value)){
td = "samsung" + td;
key = UNION_KEY + "_" + request.getClientIp() + "_" + td + "_" + request.getAppkey();
value = yhValueOperations.get(key);
activeUnion.info("activateUnion with get redis first with key={}, value={}",key, value);
}
if (StringUtils.isEmpty(value)) {
if(StringUtils.isEmpty(request.getClientIp())){
value = null;
... ...
... ... @@ -40,7 +40,7 @@ public class PinYouTask {
/**
* 每天早上6点执行
*/
@Scheduled(cron = "0 0 6 * * ?")
@Scheduled(cron = "0 0/2 6,8 * * ?")
public void run(){
log.info("begin run pinyoutask");
DynamicStringProperty taskHostPro = DynamicPropertyFactory.getInstance().getStringProperty("union.host", "172.31.16.99");
... ... @@ -52,6 +52,8 @@ public class PinYouTask {
log.warn("ScheduledPinYouTask service: execute timetask host is not local host");
return;
}
//分批执行,每次推1w条数据
int limit = 10000;
//从redis里面获取大数据的数据
Long viewSize = redisListCache.size(UNION_VIEW_KEY);
Long transSize = redisListCache.size(UNION_TRANS_KEY);
... ... @@ -61,7 +63,7 @@ public class PinYouTask {
log.info("viewSize is {},transSize is {}",viewSizeInt,transSizeInt);
List<TransPinYouRequestBO> transPinYouRequestBOList = new ArrayList<>();
if(transSizeInt>0){
for(int i=0; i < transSizeInt; i++){
for(int i=0; i < limit; i++){
TransPinYouRequestBO transPinYouRequestBO = redisListCache.rightPop(UNION_TRANS_KEY, TransPinYouRequestBO.class);
log.info("transPinYouRequestBO is {}",transPinYouRequestBO);
transPinYouRequestBOList.add(transPinYouRequestBO);
... ... @@ -69,7 +71,7 @@ public class PinYouTask {
}
if(viewSizeInt>0){
for(int i=0; i < viewSizeInt; i++){
for(int i=0; i < limit; i++){
ViewPinYouRequestBO viewPinYouRequestBO = redisListCache.rightPop(UNION_VIEW_KEY, ViewPinYouRequestBO.class);
viewPinYouRequestBOList.add(viewPinYouRequestBO);
}
... ...