...
|
...
|
@@ -13,8 +13,6 @@ import com.alibaba.fastjson.JSONObject; |
|
|
import com.netflix.config.DynamicIntProperty;
|
|
|
import com.netflix.config.DynamicPropertyFactory;
|
|
|
import com.yoho.core.cache.CacheClient;
|
|
|
import com.yoho.error.ServiceError;
|
|
|
import com.yoho.error.exception.ServiceException;
|
|
|
import com.yoho.service.model.union.request.ActiveUnionRequestBO;
|
|
|
import com.yoho.service.model.union.request.AddUnionRequestBO;
|
|
|
import com.yoho.service.model.union.response.UnionResponseBO;
|
...
|
...
|
@@ -42,26 +40,39 @@ public class DingdangServiceImpl implements DingdangService { |
|
|
private static final String unions_KEY = "unions_KEY_";
|
|
|
|
|
|
@Override
|
|
|
public UnionResponseBO addUnion(AddUnionRequestBO request) throws ServiceException {
|
|
|
public UnionResponseBO addUnion(AddUnionRequestBO request) throws Exception {
|
|
|
log.debug("addunions with param is {}", request);
|
|
|
UnionResponseBO bo = new UnionResponseBO();
|
|
|
if (StringUtils.isEmpty(request.getApp())) {
|
|
|
log.warn("addunions error app is null with param is {}", request);
|
|
|
throw new ServiceException(ServiceError.APP_IS_NULL);
|
|
|
bo.setIsSuccess(false);
|
|
|
bo.setMsg("APP_IS_NULL");
|
|
|
return bo;
|
|
|
// throw new ServiceException(ServiceError.APP_IS_NULL);
|
|
|
}
|
|
|
if (StringUtils.isEmpty(request.getUdid())) {
|
|
|
log.warn("addunions error udid is null with param is {}", request);
|
|
|
throw new ServiceException(ServiceError.UDID_IS_NULL);
|
|
|
bo.setIsSuccess(false);
|
|
|
bo.setMsg("UDID_IS_NULL");
|
|
|
return bo;
|
|
|
// throw new ServiceException(ServiceError.UDID_IS_NULL);
|
|
|
}
|
|
|
if (StringUtils.isEmpty(request.getCallbackurl())) {
|
|
|
log.warn("addunions error callbackurl is null with param is {}", request);
|
|
|
throw new ServiceException(ServiceError.CALLBACKURL_IS_NULL);
|
|
|
bo.setIsSuccess(false);
|
|
|
bo.setMsg("CALLBACKURL_IS_NULL");
|
|
|
return bo;
|
|
|
// throw new ServiceException(ServiceError.CALLBACKURL_IS_NULL);
|
|
|
}
|
|
|
|
|
|
//检查memcached中是否已经有该udid
|
|
|
AddUnionRequestBO cacheBO = cacheClient.get(unions_KEY + request.getApp() + "_" + request.getUdid(), AddUnionRequestBO.class);
|
|
|
if (cacheBO != null) {
|
|
|
log.warn("addunions error app and udid is added with param is {}", request);
|
|
|
throw new ServiceException(ServiceError.APP_UDID_IS_EXISTS);
|
|
|
bo.setIsSuccess(false);
|
|
|
bo.setMsg("APP_UDID_IS_EXISTS");
|
|
|
return bo;
|
|
|
// throw new ServiceException(ServiceError.APP_UDID_IS_EXISTS);
|
|
|
}
|
|
|
|
|
|
//保存到memcached,时间,一个小时
|
...
|
...
|
@@ -82,22 +93,28 @@ public class DingdangServiceImpl implements DingdangService { |
|
|
}
|
|
|
log.info("addunions success with param is {}", request);
|
|
|
addDingdang.info("addunions success with param is {}", request);
|
|
|
UnionResponseBO bo = new UnionResponseBO();
|
|
|
bo.setMsg("成功");
|
|
|
bo.setIsSuccess(true);
|
|
|
return bo;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public UnionResponseBO activeUnion(ActiveUnionRequestBO request) throws ServiceException {
|
|
|
public UnionResponseBO activeUnion(ActiveUnionRequestBO request) throws Exception {
|
|
|
log.debug("activeunions with param is {}", request);
|
|
|
UnionResponseBO bo = new UnionResponseBO();
|
|
|
if (StringUtils.isEmpty(request.getAppid())) {
|
|
|
log.warn("activeunions error app is null with param is {}", request);
|
|
|
throw new ServiceException(500, "APP_IS_NULL");
|
|
|
bo.setIsSuccess(false);
|
|
|
bo.setMsg("APP_IS_NULL");
|
|
|
return bo;
|
|
|
//throw new ServiceException(500, "APP_IS_NULL");
|
|
|
}
|
|
|
if (StringUtils.isEmpty(request.getUdid())) {
|
|
|
log.warn("activeunions error udid is null with param is {}", request);
|
|
|
throw new ServiceException(500, "UDID_IS_NULL");
|
|
|
bo.setIsSuccess(false);
|
|
|
bo.setMsg("UDID_IS_NULL");
|
|
|
return bo;
|
|
|
// throw new ServiceException(500, "UDID_IS_NULL");
|
|
|
}
|
|
|
|
|
|
String memKey = unions_KEY + request.getAppid() + "_" + request.getUdid();
|
...
|
...
|
@@ -106,7 +123,10 @@ public class DingdangServiceImpl implements DingdangService { |
|
|
AddUnionRequestBO cacheBO = cacheClient.get(memKey, AddUnionRequestBO.class);
|
|
|
if (cacheBO == null) {
|
|
|
log.warn("activeunions error app and udid is not exists with param is {}", request);
|
|
|
throw new ServiceException(500, "APP_UDID_IS_NOT_EXISTS");
|
|
|
bo.setIsSuccess(false);
|
|
|
bo.setMsg("APP_UDID_IS_NOT_EXISTS");
|
|
|
return bo;
|
|
|
// throw new ServiceException(500, "APP_UDID_IS_NOT_EXISTS");
|
|
|
}
|
|
|
|
|
|
//检查该app和udid是否已经激活
|
...
|
...
|
@@ -118,13 +138,19 @@ public class DingdangServiceImpl implements DingdangService { |
|
|
|
|
|
if (u == null) {
|
|
|
log.warn("activeunions error app and udid is not exists with param is {}", request);
|
|
|
throw new ServiceException(500, "APP_UDID_IS_NOT_EXISTS");
|
|
|
bo.setIsSuccess(false);
|
|
|
bo.setMsg("APP_UDID_IS_NOT_EXISTS");
|
|
|
return bo;
|
|
|
// throw new ServiceException(500, "APP_UDID_IS_NOT_EXISTS");
|
|
|
}
|
|
|
|
|
|
//已经激活
|
|
|
if ("1".equals(u.getIsActive())) {
|
|
|
log.warn("activeunions error app is actived with param is {}", request);
|
|
|
throw new ServiceException(500, "APP_UDID_IS_ACTIVED");
|
|
|
bo.setIsSuccess(false);
|
|
|
bo.setMsg("APP_UDID_IS_ACTIVED");
|
|
|
return bo;
|
|
|
// throw new ServiceException(500, "APP_UDID_IS_ACTIVED");
|
|
|
}
|
|
|
|
|
|
//调用联盟激活接口
|
...
|
...
|
@@ -152,7 +178,7 @@ public class DingdangServiceImpl implements DingdangService { |
|
|
repeatCount++;
|
|
|
}
|
|
|
log.info("call " + u.getCallbackurl() + " url return message is {}", pair.getRight());
|
|
|
UnionResponseBO bo = new UnionResponseBO();
|
|
|
|
|
|
//更新数据库
|
|
|
if (isSuccess) {
|
|
|
unions.setIsActive("1");
|
...
|
...
|
|