Authored by ping

Merge branch 'test' into pre

@@ -57,7 +57,7 @@ public class UnionRest { @@ -57,7 +57,7 @@ public class UnionRest {
57 try { 57 try {
58 UnionResponseBO bo = dingdangService.activeUnion(req); 58 UnionResponseBO bo = dingdangService.activeUnion(req);
59 if (!bo.getIsSuccess()) { 59 if (!bo.getIsSuccess()) {
60 - response.setCode(500); 60 + response.setCode(400);
61 response.setMessage(bo.getMsg()); 61 response.setMessage(bo.getMsg());
62 } else { 62 } else {
63 response.setCode(200); 63 response.setCode(200);
@@ -46,39 +46,39 @@ public class DingdangServiceImpl implements DingdangService { @@ -46,39 +46,39 @@ public class DingdangServiceImpl implements DingdangService {
46 if (StringUtils.isEmpty(request.getApp())) { 46 if (StringUtils.isEmpty(request.getApp())) {
47 log.warn("addunions error app is null with param is {}", request); 47 log.warn("addunions error app is null with param is {}", request);
48 bo.setIsSuccess(false); 48 bo.setIsSuccess(false);
49 - bo.setMsg("APP_IS_NULL"); 49 + bo.setMsg("APP IS NULL");
50 return bo; 50 return bo;
51 // throw new ServiceException(ServiceError.APP_IS_NULL); 51 // throw new ServiceException(ServiceError.APP_IS_NULL);
52 } 52 }
53 if (StringUtils.isEmpty(request.getUdid())) { 53 if (StringUtils.isEmpty(request.getUdid())) {
54 log.warn("addunions error udid is null with param is {}", request); 54 log.warn("addunions error udid is null with param is {}", request);
55 bo.setIsSuccess(false); 55 bo.setIsSuccess(false);
56 - bo.setMsg("UDID_IS_NULL"); 56 + bo.setMsg("UDID IS NULL");
57 return bo; 57 return bo;
58 // throw new ServiceException(ServiceError.UDID_IS_NULL); 58 // throw new ServiceException(ServiceError.UDID_IS_NULL);
59 } 59 }
60 if (StringUtils.isEmpty(request.getCallbackurl())) { 60 if (StringUtils.isEmpty(request.getCallbackurl())) {
61 log.warn("addunions error callbackurl is null with param is {}", request); 61 log.warn("addunions error callbackurl is null with param is {}", request);
62 bo.setIsSuccess(false); 62 bo.setIsSuccess(false);
63 - bo.setMsg("CALLBACKURL_IS_NULL"); 63 + bo.setMsg("CALLBACKURL IS NULL");
64 return bo; 64 return bo;
65 // throw new ServiceException(ServiceError.CALLBACKURL_IS_NULL); 65 // throw new ServiceException(ServiceError.CALLBACKURL_IS_NULL);
66 } 66 }
67 67
68 //检查memcached中是否已经有该udid 68 //检查memcached中是否已经有该udid
69 - AddUnionRequestBO cacheBO = cacheClient.get(unions_KEY + request.getApp() + "_" + request.getUdid(), AddUnionRequestBO.class);  
70 - log.info("addunions get cache key={}, value={}", unions_KEY + request.getApp() + "_" + request.getUdid(), cacheBO);  
71 - if (cacheBO != null) { 69 + String cacheUdid = cacheClient.get(unions_KEY + request.getApp() + "_" + request.getUdid(), String.class);
  70 + log.info("addunions get cache key={}, cacheUdid={}", unions_KEY + request.getApp() + "_" + request.getUdid(), cacheUdid);
  71 + if (StringUtils.isNotEmpty(cacheUdid)) {
72 log.warn("addunions error app and udid is added with param is {}", request); 72 log.warn("addunions error app and udid is added with param is {}", request);
73 bo.setIsSuccess(false); 73 bo.setIsSuccess(false);
74 - bo.setMsg("APP_UDID_IS_EXISTS"); 74 + bo.setMsg("APP UDID IS EXISTS");
75 return bo; 75 return bo;
76 // throw new ServiceException(ServiceError.APP_UDID_IS_EXISTS); 76 // throw new ServiceException(ServiceError.APP_UDID_IS_EXISTS);
77 } 77 }
78 78
79 //保存到memcached,时间,一个小时 79 //保存到memcached,时间,一个小时
80 DynamicIntProperty activeTime = DynamicPropertyFactory.getInstance().getIntProperty("activeTime", 60 * 60); 80 DynamicIntProperty activeTime = DynamicPropertyFactory.getInstance().getIntProperty("activeTime", 60 * 60);
81 - cacheClient.set(unions_KEY + request.getApp() + "_" + request.getUdid(), activeTime.get(), request); 81 + cacheClient.set(unions_KEY + request.getApp() + "_" + request.getUdid(), activeTime.get(), request.getUdid());
82 log.debug("addunions set cache success"); 82 log.debug("addunions set cache success");
83 //插入数据库 83 //插入数据库
84 try { 84 try {
@@ -106,14 +106,14 @@ public class DingdangServiceImpl implements DingdangService { @@ -106,14 +106,14 @@ public class DingdangServiceImpl implements DingdangService {
106 if (StringUtils.isEmpty(request.getAppid())) { 106 if (StringUtils.isEmpty(request.getAppid())) {
107 log.warn("activeunions error app is null with param is {}", request); 107 log.warn("activeunions error app is null with param is {}", request);
108 bo.setIsSuccess(false); 108 bo.setIsSuccess(false);
109 - bo.setMsg("APP_IS_NULL"); 109 + bo.setMsg("APP IS NULL");
110 return bo; 110 return bo;
111 //throw new ServiceException(500, "APP_IS_NULL"); 111 //throw new ServiceException(500, "APP_IS_NULL");
112 } 112 }
113 if (StringUtils.isEmpty(request.getUdid())) { 113 if (StringUtils.isEmpty(request.getUdid())) {
114 log.warn("activeunions error udid is null with param is {}", request); 114 log.warn("activeunions error udid is null with param is {}", request);
115 bo.setIsSuccess(false); 115 bo.setIsSuccess(false);
116 - bo.setMsg("UDID_IS_NULL"); 116 + bo.setMsg("UDID IS NULL");
117 return bo; 117 return bo;
118 // throw new ServiceException(500, "UDID_IS_NULL"); 118 // throw new ServiceException(500, "UDID_IS_NULL");
119 } 119 }
@@ -121,14 +121,13 @@ public class DingdangServiceImpl implements DingdangService { @@ -121,14 +121,13 @@ public class DingdangServiceImpl implements DingdangService {
121 String memKey = unions_KEY + request.getAppid() + "_" + request.getUdid(); 121 String memKey = unions_KEY + request.getAppid() + "_" + request.getUdid();
122 122
123 //检查memcached中是否已经有该udid 123 //检查memcached中是否已经有该udid
124 - AddUnionRequestBO cacheBO = cacheClient.get(memKey, AddUnionRequestBO.class);  
125 - log.info("activeUnion get cache key={}, value={}", memKey, cacheBO);  
126 - if (cacheBO == null) { 124 + String cacheUdid = cacheClient.get(memKey, String.class);
  125 + log.info("activeUnion get cache key={}, cacheUdid={}", memKey, cacheUdid);
  126 + if (StringUtils.isEmpty(cacheUdid)) {
127 log.warn("activeunions error app and udid is not exists with param is {}", request); 127 log.warn("activeunions error app and udid is not exists with param is {}", request);
128 bo.setIsSuccess(false); 128 bo.setIsSuccess(false);
129 - bo.setMsg("APP_UDID_IS_NOT_EXISTS"); 129 + bo.setMsg("APP UDID IS NOT EXISTS IN CACHE");
130 return bo; 130 return bo;
131 -// throw new ServiceException(500, "APP_UDID_IS_NOT_EXISTS");  
132 } 131 }
133 132
134 //检查该app和udid是否已经激活 133 //检查该app和udid是否已经激活
@@ -141,18 +140,16 @@ public class DingdangServiceImpl implements DingdangService { @@ -141,18 +140,16 @@ public class DingdangServiceImpl implements DingdangService {
141 if (u == null) { 140 if (u == null) {
142 log.warn("activeunions error app and udid is not exists with param is {}", request); 141 log.warn("activeunions error app and udid is not exists with param is {}", request);
143 bo.setIsSuccess(false); 142 bo.setIsSuccess(false);
144 - bo.setMsg("APP_UDID_IS_NOT_EXISTS"); 143 + bo.setMsg("database has not exists this udid but cache exists");
145 return bo; 144 return bo;
146 -// throw new ServiceException(500, "APP_UDID_IS_NOT_EXISTS");  
147 } 145 }
148 146
149 //已经激活 147 //已经激活
150 if ("1".equals(u.getIsActive())) { 148 if ("1".equals(u.getIsActive())) {
151 log.warn("activeunions error app is actived with param is {}", request); 149 log.warn("activeunions error app is actived with param is {}", request);
152 bo.setIsSuccess(false); 150 bo.setIsSuccess(false);
153 - bo.setMsg("APP_UDID_IS_ACTIVED"); 151 + bo.setMsg("app udid had actived");
154 return bo; 152 return bo;
155 -// throw new ServiceException(500, "APP_UDID_IS_ACTIVED");  
156 } 153 }
157 154
158 //调用联盟激活接口 155 //调用联盟激活接口