Authored by ping

Merge branch 'test' into pre

... ... @@ -57,7 +57,7 @@ public class UnionRest {
try {
UnionResponseBO bo = dingdangService.activeUnion(req);
if (!bo.getIsSuccess()) {
response.setCode(500);
response.setCode(400);
response.setMessage(bo.getMsg());
} else {
response.setCode(200);
... ...
... ... @@ -46,39 +46,39 @@ public class DingdangServiceImpl implements DingdangService {
if (StringUtils.isEmpty(request.getApp())) {
log.warn("addunions error app is null with param is {}", request);
bo.setIsSuccess(false);
bo.setMsg("APP_IS_NULL");
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);
bo.setIsSuccess(false);
bo.setMsg("UDID_IS_NULL");
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);
bo.setIsSuccess(false);
bo.setMsg("CALLBACKURL_IS_NULL");
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);
log.info("addunions get cache key={}, value={}", unions_KEY + request.getApp() + "_" + request.getUdid(), cacheBO);
if (cacheBO != null) {
String cacheUdid = cacheClient.get(unions_KEY + request.getApp() + "_" + request.getUdid(), String.class);
log.info("addunions get cache key={}, cacheUdid={}", unions_KEY + request.getApp() + "_" + request.getUdid(), cacheUdid);
if (StringUtils.isNotEmpty(cacheUdid)) {
log.warn("addunions error app and udid is added with param is {}", request);
bo.setIsSuccess(false);
bo.setMsg("APP_UDID_IS_EXISTS");
bo.setMsg("APP UDID IS EXISTS");
return bo;
// throw new ServiceException(ServiceError.APP_UDID_IS_EXISTS);
}
//保存到memcached,时间,一个小时
DynamicIntProperty activeTime = DynamicPropertyFactory.getInstance().getIntProperty("activeTime", 60 * 60);
cacheClient.set(unions_KEY + request.getApp() + "_" + request.getUdid(), activeTime.get(), request);
cacheClient.set(unions_KEY + request.getApp() + "_" + request.getUdid(), activeTime.get(), request.getUdid());
log.debug("addunions set cache success");
//插入数据库
try {
... ... @@ -106,14 +106,14 @@ public class DingdangServiceImpl implements DingdangService {
if (StringUtils.isEmpty(request.getAppid())) {
log.warn("activeunions error app is null with param is {}", request);
bo.setIsSuccess(false);
bo.setMsg("APP_IS_NULL");
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);
bo.setIsSuccess(false);
bo.setMsg("UDID_IS_NULL");
bo.setMsg("UDID IS NULL");
return bo;
// throw new ServiceException(500, "UDID_IS_NULL");
}
... ... @@ -121,14 +121,13 @@ public class DingdangServiceImpl implements DingdangService {
String memKey = unions_KEY + request.getAppid() + "_" + request.getUdid();
//检查memcached中是否已经有该udid
AddUnionRequestBO cacheBO = cacheClient.get(memKey, AddUnionRequestBO.class);
log.info("activeUnion get cache key={}, value={}", memKey, cacheBO);
if (cacheBO == null) {
String cacheUdid = cacheClient.get(memKey, String.class);
log.info("activeUnion get cache key={}, cacheUdid={}", memKey, cacheUdid);
if (StringUtils.isEmpty(cacheUdid)) {
log.warn("activeunions error app and udid is not exists with param is {}", request);
bo.setIsSuccess(false);
bo.setMsg("APP_UDID_IS_NOT_EXISTS");
bo.setMsg("APP UDID IS NOT EXISTS IN CACHE");
return bo;
// throw new ServiceException(500, "APP_UDID_IS_NOT_EXISTS");
}
//检查该app和udid是否已经激活
... ... @@ -141,18 +140,16 @@ public class DingdangServiceImpl implements DingdangService {
if (u == null) {
log.warn("activeunions error app and udid is not exists with param is {}", request);
bo.setIsSuccess(false);
bo.setMsg("APP_UDID_IS_NOT_EXISTS");
bo.setMsg("database has not exists this udid but cache 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);
bo.setIsSuccess(false);
bo.setMsg("APP_UDID_IS_ACTIVED");
bo.setMsg("app udid had actived");
return bo;
// throw new ServiceException(500, "APP_UDID_IS_ACTIVED");
}
//调用联盟激活接口
... ...