Showing
1 changed file
with
22 additions
and
169 deletions
@@ -129,7 +129,7 @@ public class ClickUnionRest { | @@ -129,7 +129,7 @@ public class ClickUnionRest { | ||
129 | */ | 129 | */ |
130 | @RequestMapping("/addUnion4Special") | 130 | @RequestMapping("/addUnion4Special") |
131 | public void addUnion4Special(ClickUnionRequestBO bo, HttpServletRequest request, HttpServletResponse response) { | 131 | public void addUnion4Special(ClickUnionRequestBO bo, HttpServletRequest request, HttpServletResponse response) { |
132 | - clickUnion.info("addUnion4Special with param is {}", bo); | 132 | + log.info("addUnion4Special with param is {}", bo); |
133 | try { | 133 | try { |
134 | String clientIp = null; | 134 | String clientIp = null; |
135 | String IP = RemoteIPInterceptor.getRemoteIP(); | 135 | String IP = RemoteIPInterceptor.getRemoteIP(); |
@@ -139,47 +139,28 @@ public class ClickUnionRest { | @@ -139,47 +139,28 @@ public class ClickUnionRest { | ||
139 | } | 139 | } |
140 | bo.setClientIp(clientIp); | 140 | bo.setClientIp(clientIp); |
141 | String agent = request.getHeader("user-agent"); | 141 | String agent = request.getHeader("user-agent"); |
142 | - agent = agent.toLowerCase(); | ||
143 | - clickUnion.info("user-agent={}", agent); | ||
144 | - | ||
145 | - String url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8"; | ||
146 | - | ||
147 | - try{ | ||
148 | - if (!StringUtils.isEmpty(agent)) { | ||
149 | - //对encode的进行处理 | ||
150 | - String agentEncode = URLDecoder.decode(agent, "UTF-8"); | ||
151 | - if (!agent.equals(agentEncode)) { //encode前后不相等,说明经过了encode处理,则需要decode | ||
152 | - agent = agentEncode; | ||
153 | - } | ||
154 | - | ||
155 | - if (agent.indexOf("mac os x") >= 0 || agent.indexOf("iphone") >= 0 || agent.indexOf("ipad") > 0) { | ||
156 | - setClickUnionRequestBO(agent, bo, url); | ||
157 | - } | ||
158 | - } | ||
159 | - }catch (Exception e){ | ||
160 | - log.error("addUnion4Special error with request={}", bo, e); | 142 | + log.info("user-agent={}", agent); |
143 | + if (StringUtils.isEmpty(agent)) { | ||
144 | + log.warn("addUnion4Special user-agent is empty with bo={}", bo); | ||
145 | + return; | ||
146 | + } | ||
147 | + if (agent.toLowerCase().indexOf("mac os x") < 0 && agent.toLowerCase().indexOf("iphone") < 0) { | ||
148 | + log.warn("addUnion4Special is not ios with user-agent={}, bo={}", agent, bo); | ||
149 | + return; | ||
161 | } | 150 | } |
162 | -// if (StringUtils.isEmpty(agent)) { | ||
163 | -// log.warn("addUnion4Special user-agent is empty with bo={}", bo); | ||
164 | -// return; | ||
165 | -// } | ||
166 | -// if (agent.toLowerCase().indexOf("mac os x") < 0 && agent.toLowerCase().indexOf("iphone") < 0) { | ||
167 | -// log.warn("addUnion4Special is not ios with user-agent={}, bo={}", agent, bo); | ||
168 | -// return; | ||
169 | -// } | ||
170 | -// if (agent.indexOf(" like") < agent.indexOf(" OS ") + 4) { | ||
171 | -// log.warn("addUnion4Special agent is not correct with user-agent={}, bo={}", agent, bo); | ||
172 | -// return; | ||
173 | -// } | ||
174 | -// | ||
175 | -// String version = agent.substring(agent.indexOf(" OS ") + 4, agent.indexOf(" like")); | ||
176 | -// clickUnion.info("addUnion4Special version={}", version); | ||
177 | -// bo.setTd("ios_" + version.replaceAll("_", ".")); | ||
178 | -// bo.setClient_type("ios"); | ||
179 | -// bo.setAppid("490655927"); | ||
180 | -// log.info("addUnion4Special request={}", bo); | 151 | + if (agent.indexOf(" like") < agent.indexOf(" OS ") + 4) { |
152 | + log.warn("addUnion4Special agent is not correct with user-agent={}, bo={}", agent, bo); | ||
153 | + return; | ||
154 | + } | ||
155 | + | ||
156 | + String version = agent.substring(agent.indexOf(" OS ") + 4, agent.indexOf(" like")); | ||
157 | + log.info("addUnion4Special version={}", version); | ||
158 | + bo.setTd("ios_" + version.replaceAll("_", ".")); | ||
159 | + bo.setClient_type("ios"); | ||
160 | + bo.setAppid("490655927"); | ||
161 | + log.info("addUnion4Special request={}", bo); | ||
181 | unionService.clickUnion(bo); | 162 | unionService.clickUnion(bo); |
182 | -// log.info("addUnion4Special with result is {}, and request is {}", response, bo); | 163 | + log.info("addUnion4Special with result is {}, and request is {}", response, bo); |
183 | clickUnion.info("addUnion4Special request is {}", bo); | 164 | clickUnion.info("addUnion4Special request is {}", bo); |
184 | response.setStatus(301); | 165 | response.setStatus(301); |
185 | response.sendRedirect("https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8"); | 166 | response.sendRedirect("https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8"); |
@@ -187,135 +168,7 @@ public class ClickUnionRest { | @@ -187,135 +168,7 @@ public class ClickUnionRest { | ||
187 | log.error("addUnion4Special error with request={}", bo, e); | 168 | log.error("addUnion4Special error with request={}", bo, e); |
188 | } | 169 | } |
189 | } | 170 | } |
190 | - | ||
191 | - private void setClickUnionRequestBO(String agent, ClickUnionRequestBO bo, String url) throws UnsupportedEncodingException { | ||
192 | - if(agent.contains("os")&&agent.contains("like")){ | ||
193 | - String version = agent.substring(agent.indexOf(" os ") + 4, agent.indexOf(" like")); | ||
194 | - bo.setTd("ios_" + version.replaceAll("_", ".")); | ||
195 | - bo.setClient_type("ios"); | ||
196 | - bo.setAppid("490655927"); | ||
197 | - url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8"; | ||
198 | - } | ||
199 | - //youku;5.4;ios;10.2;iphone6,1 ---这种情况比较多 | ||
200 | - else if(agent.contains("youku")){ | ||
201 | - String version = ""; | ||
202 | - if(agent.contains("ios")){ | ||
203 | - int first = agent.indexOf("ios;")+4; | ||
204 | - String version1 = agent.substring(first); | ||
205 | - version = version1.substring(version1.indexOf(" ")+1, version1.indexOf(";")); | ||
206 | - bo.setTd("ios_" + version.replaceAll("_", ".")); | ||
207 | - bo.setClient_type("ios"); | ||
208 | - bo.setAppid("490655927"); | ||
209 | - url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8"; | ||
210 | - } //youku;5.4.1;iphone os;8.4.1;iphone6,2 | ||
211 | - else if(agent.contains("os")){ | ||
212 | - int first = agent.indexOf("os;") + 3; | ||
213 | - String version1 = agent.substring(first); | ||
214 | - version = version1.substring(version1.indexOf(" ") + 1, version1.indexOf(";")); | ||
215 | - bo.setTd("ios_" + version.replaceAll("_", ".")); | ||
216 | - bo.setClient_type("ios"); | ||
217 | - bo.setAppid("490655927"); | ||
218 | - url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8"; | ||
219 | - } | ||
220 | - } | ||
221 | - //momochat/7.5.6 ios/664 (iphone 6; ios 10.2; zh_cn; iphone7,2; s1) | ||
222 | - else if(agent.contains("momochat")){ | ||
223 | - String version = ""; | ||
224 | - if(agent.contains("ios")){ | ||
225 | - int first = agent.indexOf(" ios ")+4; | ||
226 | - String version1 = agent.substring(first); | ||
227 | - version = version1.substring(version1.indexOf(" ")+1, version1.indexOf(";")); | ||
228 | - bo.setTd("ios_" + version.replaceAll("_", ".")); | ||
229 | - bo.setClient_type("ios"); | ||
230 | - bo.setAppid("490655927"); | ||
231 | - url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8"; | ||
232 | - } //momochat/7.5.6 ios/664 (iphone 6s; iphone os 9.2; zh_cn; iphone8,1; s1) | ||
233 | - else if(agent.contains("os")){ | ||
234 | - int first = agent.indexOf(" os ")+3; | ||
235 | - String version1 = agent.substring(first); | ||
236 | - version = version1.substring(version1.indexOf(" ")+1, version1.indexOf(";")); | ||
237 | - bo.setTd("ios_" + version.replaceAll("_", ".")); | ||
238 | - bo.setClient_type("ios"); | ||
239 | - bo.setAppid("490655927"); | ||
240 | - url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8"; | ||
241 | - } | ||
242 | - } | ||
243 | - else if(agent.contains("ios/")){ | ||
244 | - String version= ""; | ||
245 | - if(agent.contains("mozilla")){ // mozilla/5.0,ios/10.0.2,client/5.8.1,device/iphone6.2,theme/red | ||
246 | - version = agent.substring(agent.indexOf("ios/")+4,agent.indexOf("client")-1); | ||
247 | - }else if (agent.contains("iphone")) { //huazhu/ios/iphone9,2/10.2.1/6.5.3 | ||
248 | - int last = agent.lastIndexOf("/"); | ||
249 | - String version1 = agent.substring(0,last); | ||
250 | - version = version1.substring(version1.lastIndexOf("/") + 1, version1.length()); | ||
251 | - bo.setTd("ios_" + version.replaceAll("_", ".")); | ||
252 | - bo.setClient_type("ios"); | ||
253 | - bo.setAppid("490655927"); | ||
254 | - url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8"; | ||
255 | - }else{ //ios/6.6 com.jugg.doctor ipad5,3/8.3/768x1024/2.0 /1---这个应该就是ios_6.6 | ||
256 | - version = agent.substring(agent.indexOf("ios/")+4,agent.indexOf(" ")); | ||
257 | - bo.setTd("ios_" + version.replaceAll("_", ".")); | ||
258 | - bo.setClient_type("ios"); | ||
259 | - bo.setAppid("490655927"); | ||
260 | - url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8"; | ||
261 | - } | ||
262 | - } | ||
263 | - //365jia news client/cn.ahurls.news/3.5.0_300500.209/ios(7.1|0|iphone)/59c2ed8b88175124c539e0c7a96a18d4eedb3d6c(none|none)/640x1136@2 | ||
264 | - else if(agent.contains("/ios")){ | ||
265 | - int first = agent.indexOf("/ios(") + 5; | ||
266 | - String version1 = agent.substring(first); | ||
267 | - String version = version1.substring(0,version1.indexOf("|")); | ||
268 | - bo.setTd("ios_" + version.replaceAll("_", ".")); | ||
269 | - bo.setClient_type("ios"); | ||
270 | - bo.setAppid("490655927"); | ||
271 | - url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8"; | ||
272 | - } | ||
273 | - else if (agent.contains("ios")){ | ||
274 | - String version = ""; | ||
275 | - if(agent.contains("letvshop")){ | ||
276 | - //letvshop;1.6.6;iphone 6plus;ios-iphone;9.2;zh_cn | ||
277 | - int lastIndex = agent.lastIndexOf(";"); | ||
278 | - String version1 = agent.substring(0,lastIndex); | ||
279 | - version = agent.substring(version1.lastIndexOf(";")+1,lastIndex); | ||
280 | - bo.setTd("ios_" + version.replaceAll("_", ".")); | ||
281 | - bo.setClient_type("ios"); | ||
282 | - bo.setAppid("490655927"); | ||
283 | - url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8"; | ||
284 | - }else if(agent.contains("jxsg")) { //jxsg_ios-1.2.5/0.0.2 (iphone7,2; ios 10.2.1) | ||
285 | - int first = agent.lastIndexOf("ios ") + 4; | ||
286 | - String version1 = agent.substring(first); | ||
287 | - int lastIndex = version1.indexOf(")"); | ||
288 | - version = version1.substring(version1.indexOf(" ") + 1, lastIndex); | ||
289 | - bo.setTd("ios_" + version.replaceAll("_", ".")); | ||
290 | - bo.setClient_type("ios"); | ||
291 | - bo.setAppid("490655927"); | ||
292 | - url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8"; | ||
293 | - }else{ | ||
294 | - int first = agent.lastIndexOf("ios ") + 4; | ||
295 | - String version1 = agent.substring(first); | ||
296 | - int lastIndex = version1.indexOf(";"); | ||
297 | - version = version1.substring(0, lastIndex); | ||
298 | - bo.setTd("ios_" + version.replaceAll("_", ".")); | ||
299 | - bo.setClient_type("ios"); | ||
300 | - bo.setAppid("490655927"); | ||
301 | - url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8"; | ||
302 | - } | ||
303 | - } | ||
304 | - } | ||
305 | - | ||
306 | - public static void main(String[] args) { | ||
307 | - String agent = "Mozilla/5.0 (iPhone; CPU iPhone OS like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile TADChid/0 AppVersion/4.5.0"; | ||
308 | - agent = "Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Mobile/13B143 TADChid/0 AppVersion/4.8.5"; | ||
309 | - if (agent.toLowerCase().indexOf("mac os x") < 0 && agent.toLowerCase().indexOf("iphone") < 0) { | ||
310 | - return; | ||
311 | - } | ||
312 | - if (agent.indexOf(" like") < agent.indexOf(" OS ") + 4) { | ||
313 | - return; | ||
314 | - } | ||
315 | - String version = agent.substring(agent.indexOf(" OS ") + 4, agent.indexOf(" like")); | ||
316 | - log.info("addUnion4Special version={}", version); | ||
317 | - } | ||
318 | - | 171 | + |
319 | @RequestMapping("/addUnion4Jump") | 172 | @RequestMapping("/addUnion4Jump") |
320 | public void addUnion4Stream(ClickUnionRequestBO bo, HttpServletRequest request, HttpServletResponse response) { | 173 | public void addUnion4Stream(ClickUnionRequestBO bo, HttpServletRequest request, HttpServletResponse response) { |
321 | clickUnion.info("addUnion4Stream ClickUnionRequestBO{}", bo); | 174 | clickUnion.info("addUnion4Stream ClickUnionRequestBO{}", bo); |
-
Please register or login to post a comment